Basically trying to learn Python and I was doing the hackerrank 30 day challenge. Task Given an integer, n , perform the following conditional actions:
If n is odd, print ok If n is even and in the inclusive range of 2 to 5, print nok
n = 4
if n in range(2,5) and type(n/2) == int:
print ("ok")
else:
print ("nok")
it prints "nok" no matter what n is.
Aucun commentaire:
Enregistrer un commentaire