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.

- Prepare
- Python
- Introduction
- Python If-Else
- Discussions

# Python If-Else

# Python If-Else

+ 0 comments if

**name**== '**main**':`n = int(input().strip())`

if n%2!=0: print("Weird") elif (n%2==0) and n in range(1,6): print("Not Weird") elif (n%2==0) and n in range(5,21): print("Weird") elif (n%2==0) and (n>20): print("Not Weird")

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

+ 0 comments Hey there, can someone please help out on how to code the if - else (python) part where you have 'n' as even or odd and then you print it accordingly. If you know it, then please help me understand the process. Thank you : )

+ 0 comments Anyone let me know where I did mistake?

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

+ 0 comments can we not use the range function here?

Load more conversations

Sort 3121 Discussions, By:

Please Login in order to post a comment