vendredi 5 mars 2021

Python: If statement not working/being ignored [closed]

I am having an issue with an if statement that I cannot figure out on my own. I am sure it's simple, but it seems to be beyond my scope of Python knowledge. I am still very new. I am making a decision based text adventure mini game. Everything is working except for one if statement.

# Python Practice Project! Conversation Minigame
import time 
print("For this game you only need to respond with (A) or (B)*Without parenthesis*")
time.sleep(3)
print("This is a conversation minigame that has different outcomes based on the decisions you make")
time.sleep(4)
answer = input("So, would you like to play? (Answer (A) \"Yes\" or (B) \"No\"): ")
if answer == "A":
    answer = input("Hello! (Answer back with (A) \"Hi!\" or (B) \"What\"): ")
    if answer == "A":
        answer = input("Do you happen to know where the store is? (Answer with (A) \"Yes, it's right over there to the left.\" or (B) \"Why should I help you?\"): ")
        
        if answer == "A":
            print("Thank you so much!\n(Good Ending)\nEnding 1-6")
        elif answer == "B":
            answer == input("Gosh! All I did was ask a question! What did I ever do to you? (Answer back with (A) \"Sorry, the store is just over there to the left.\" or (B) \"Well maybe if you wore your glasses, you would be able see that the store is right over there!\"): ")
            
            if answer == "A":
                print("Huff!\n(Bad Ending)\nEnding 2-6")
                
            elif answer == "B":
                print("Unbelievable! You are so rude! I hope I never come across you again!\n(Very Bad Ending)\nEnding 3-5")
            
            else:
                print("That not a valid answer")
            
        else:
            print("That is not a valid answer")
        
    elif answer == "B":
        answer = input("Hey! You don't have to be so rude you know? (Answer back with (A) \"Oh sorry, you just caught me off guard.\" or (B) \"Whatever\"): ")
        
        if answer == "A":
            answer = input("Oh, sorry about that. (Answer back with (A) \"It's ok\" or (B) \"Sure you are\"): ")
        
        elif answer == "B":
            answer = input("What is up with you? Why are you so rude? (Answer back with (A) \"Sorry, I just don't like it when random people ask me questions.\" or (B) \"Have you ever though that you were the problem?\"): ")
            if answer == "A":
                answer = input("Wow ok, well can you just tell me where the store is? (Answer back with (A) \"Yes, it's right over there to the left.\" or (B) \"Ugh fine, it's right over there to the left.\"): ")
                if answer == "A":
                    print("Thanks.\n(Not so good ending)\nEnding 5-6")
                    
                elif answer == "B":
                    print("*OOF* (You just got punched in the gut) Jerk!\n(Oof ending)\nEnding 6-6")
                    
            elif answer == "B":
                print("*SMACK* (You were just back-handed across the face) I'll just find the store myself!\n(You got owned ending)\nEnding 4-5 ")
                
            else:
                print("That is not a valid answer")
                
        else:
            print("That is not a valid answer.")
        
    else:
        print("That's not a valid answer")
    

else:
    print("That's too bad. (No hard feelings! :>")

I'm really Sorry if it looks messed up, this is my first time asking a question on here. The line that won't work is if answer == "A": print("Huff!\n(Bad Ending)\nEnding 2-6")

The line doesn't give an error but it gets ignored. When ever I try and type "A" it just prints the elif statement which is elif answer == "B": print("Unbelievable! You are so rude! I hope I never come across you again!\n(Very Bad Ending)\nEnding 3-5")

So, from what I see it seems like it is being skipped or ignored, but I'm not sure, so I came here for help on resolving this issue. I've tried rewriting it, but I just get this same issue. I've been working on this game for days after many fails, and I was sure that I finally mastered the if statements, but guess I was wrong on that one. So, if anyone might know how to solve this issue it would be greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire