We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
n = int(input().strip())
word = {True: "Not Weird", False: "Weird"}
print(word[ n % 2 == 0 and (n in range (2, 7) or n > 21)])
it failed on me but fixed itself when fixing the ranges becasue 6 and 20 isnt read
i compared it to the if else statements i made
if n % 2 == 0 and n in range (2, 7):
print("Not Weird")
elif n % 2 == 0 and n in range (7, 21):
print("Weird")
elif n % 2 == 0 and n > 20:
print("Not Weird")
elif n % 2 == 1:
print("Weird")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Python If-Else
You are viewing a single comment's thread. Return to all comments →
it failed on me but fixed itself when fixing the ranges becasue 6 and 20 isnt read
i compared it to the if else statements i made if n % 2 == 0 and n in range (2, 7): print("Not Weird") elif n % 2 == 0 and n in range (7, 21): print("Weird") elif n % 2 == 0 and n > 20: print("Not Weird") elif n % 2 == 1: print("Weird")