[Solved] Python: if-else statement, printing ‘Weird’ if a given integer is odd or it’s even but within a particular range shown below, and ‘Not Weird’ if not [closed]


I hope this helps! If this is not exactly what you were looking for, you can still use my code but reorganize the parts.

n = int(input('Write your number : ').strip())

if n % 2 == 1:
    #n is odd
    print ("Weird")

else:
    #n is even
    if 2 <= n <= 5:
        #n between 2 and 5 inclusive
        print("Not Weird")

    elif 6 <= n <= 20:
        #n between 6 and 20 inclusive
        print("Weird")

    elif n > 20:
        #n greater than 20
        print("Not Weird")

solved Python: if-else statement, printing ‘Weird’ if a given integer is odd or it’s even but within a particular range shown below, and ‘Not Weird’ if not [closed]