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
  • 2,088
  • 3
  • 16
  • I'm sorry, I am still learning. Thank you! –  Oct 08 '20 at 04:57
  • @ConstantinShimonenko Nothing to be sorry about! You are learning something new and this is brilliant! Don't worry about such things, you will master them soon enough, Good luck! – Or Y Oct 08 '20 at 04:58
0

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

Mihir
  • 520
  • 2
  • 6
  • 18