0

Python seems to skip my if statement.

is_hot = ""
true_or_false = input("True or False? ").lower()

if true_or_false == "true":
    is_hot == True
elif true_or_false == "false":
    is_hot == False
else:
    print("You didn't type true or false")

#The skipped if statement:
if is_hot == True:
    print("It's a hot day")
    print("Drink water.")
elif is_hot == False:
    print("It's not hot.")

print("Enjoy your day")

The output is just the last print statement.

2 Answers2

3

Your problem is with the assignment to is_hot.

change:

if true_or_false == "true":
    is_hot == True
elif true_or_false == "false":
    is_hot == False

to:

if true_or_false == "true":
    is_hot = True
elif true_or_false == "false":
    is_hot = False

Notice the single =? That means an assignment whereas == means comparison.

Or Y
  • 1,923
  • 1
  • 15
0

It should just be a single = instead of == for is_hot

Mihir
  • 320
  • 2
  • 3
  • 14