1

I am a beginner at programming and I am trying to get my program to work. In my program I ask two questions from the user and if both answers == "1", then my variable A should change to "Blue" However, it's not working. Could someone tell me why?

Thanks.

print("Q1")

A = input(">>>")

if A == "1":
    A = "Red"

print("Q2")

B = input(">>>")

if B == "1":
    B = "Red"

if A == "1" and B == "1":
        A = "Blue"

print(A)
1
  • 1
    Notice that you changed A = "Red" so it no longer is "1". Commented Mar 20, 2022 at 18:41

1 Answer 1

1

You are setting the variable A to red then you check if A == 1 essentially comparing RED == 1 which will always be false. Try changing the name of the variable you assign RED and BLUE to

##test ##

print("Q1")

A = str(input(">>>"))

if A == "1": A_result = "Red"

print("Q2")

B = input(">>>")

if B == "1": B_result = "Red"

if A == "1" and B == "1": A_result = "Blue"

print(A_result)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.