mardi 14 novembre 2017

How to evaluate multiple expression in if--elif statement in python?

How to evaluate multiple expression in if--elif in below code snipet.

I am sure its basic syntax issue

n=5
if n%2 != 0:    
    print ("weird")    
elif n%2 == 0 && 2 < n && n <5:    
    print "Not Weird"
elif n%2 == 0 && 6 < n && n < 20:
    print "Weird"
elif n%2 == 0 && n >20:
    print "NOt Weird"

Aucun commentaire:

Enregistrer un commentaire