dimanche 12 juillet 2020

if else Conditions

The problem is like this

My solution:

n= int(input())
if n%2==0:
    if (n >=2 & n<=5):
        print("Not Weird")
    elif n >=6 & n<=20:
        print("Weird")
    else:
        print ("Not Weired")
else:
    print ("Weird")

Now, if I enter 18 then it should be printed "Weird". But it is showing "Not Weird".

I am not getting where the problem of my code is.

Aucun commentaire:

Enregistrer un commentaire