mardi 30 juillet 2019

Simple if-else failing test case [on hold]

This is a HackerRank problem and about as simple as it gets. But it's failing when test case is 4. Says expected output is "Not Weird." Isn't this covered by that first elif statement?

I have no idea what else to try.

if n % 2 == 1:
    print("Weird")
elif n % 2 == 0 and n >= 2 and n <= 5:
    print("Not weird")
elif n % 2 == 0 and n >= 6 and n <= 20:
    print("Weird")
else: 
    print("Not Weird")

Aucun commentaire:

Enregistrer un commentaire