dimanche 14 janvier 2018

Python: Multiple if-statements, No output [on hold]

I used multiple if-statements instead of elif-statements.

If I assign a value less than 10 for the variable x (i.e. I make the first if-statement true), the output prints.

However, any value that makes the other if-statements true (i.e. a value between 10-25 that makes the 2nd if-statement true, or a value greater than 25 that makes the 3rd if-statement true), no output prints (no error or anything, just a blank space). Can anyone explain why?

if x <= 10: 
    print ('less than 10')

if x <= 25 and x > 10:
    print ('between 10 and 25')

if x > 25:
    print ('greater than 25')

Aucun commentaire:

Enregistrer un commentaire