samedi 27 novembre 2021

elif not behaving as expected - beginner/ noob problems

I have a half dozen if and elif statements and the second elif won't work. It has something to do with the less than sign because the greater than sign works Why?

elif temperature < 10:
   print("Don't bother getting out of bed")

Complete source:

temperature = 3

if temperature > 30:
    print("Its a hot day, drink plenty of water")
if temperature < 15:
    print("No need to drink any water today")
elif temperature > 39:
    print("Its really hot so stay indoors")
elif temperature < 10:
    print("Don't bother getting out of bed")
else:
    print("Its a lovely day today")

# this returns:
# No need to drink any water today
# Process finished with exit code 0

https://github.com/Destria-black/Learning.git

Aucun commentaire:

Enregistrer un commentaire