You are viewing a single comment's thread. Return to all comments →
Guys i need help. My code doesnt work with test case 7 and 3. There are numbers 18 and 20 which are supposed to be weird but they're not. my code:
if name == 'main': n = float(input().strip()) if (n%2) != 0 : print("Weird") elif (n%2) == 0 and range(2, 5): print("Not Weird") elif (n%2) == 0 and range(6, 20) : print("Weird") elif (n%2) == 0 and n > 20: print("Not Weird") else: print("Error")
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Python If-Else
You are viewing a single comment's thread. Return to all comments →
Guys i need help. My code doesnt work with test case 7 and 3. There are numbers 18 and 20 which are supposed to be weird but they're not. my code:
if name == 'main': n = float(input().strip()) if (n%2) != 0 : print("Weird") elif (n%2) == 0 and range(2, 5): print("Not Weird") elif (n%2) == 0 and range(6, 20) : print("Weird") elif (n%2) == 0 and n > 20: print("Not Weird") else: print("Error")