+ 2

What I did wrong in this?? Help me friends.

n = int(input) If n%2!=0: print ("Weird") elif n%2==0 or n%2!=0 in range (2,5): print ("Not Weird") elif n%2==0 in range(6,20): print("Weird") elif n%2==0 and n>20: print ("Not Weird") """ The problem is when i give input 16 it shows ("Not Weird") , But it should print ("Weird") """

9th Apr 2020, 7:40 AM
SelvaKumar
11 ответов
9th Apr 2020, 7:52 AM
Oma Falk
Oma Falk - avatar
+ 1
try this n = int(input()) if n%2!=0: print ("Weird") elif n%2==0 and n in range (2,6): print ("Not Weird") elif n%2==0 and n in range(6,21): print("Weird") elif n%2==0 and n>20: print ("Not Weird")
9th Apr 2020, 8:04 AM
John Robotane
John Robotane - avatar
+ 1
This codes is well ordered. For me i think that for those conditional statememts they should be imposed on n not on n%2 HOPE THIS HELPS https://code.sololearn.com/c8VOf5fIpbQO/?ref=app
11th Apr 2020, 12:53 AM
Josaphat NGOGA UWIZEYE
Josaphat NGOGA UWIZEYE - avatar
+ 1
Here 16 is not a weird number,and the smallest weird number is 70 A number is said to be weird if the sum of proper divisors of that number(except itself) are greater than the given number. Example:the number 70 The divisors of 70 are 1,2,5,7,10,14 and 35.whose sum is 74. Here 74 is greater than 70
11th Apr 2020, 7:28 AM
Mannam Rama krishna
Mannam Rama krishna - avatar
0
what do you mean by: n%2!=0 in range(2,5) or n%2==0 in range(6,20)
9th Apr 2020, 7:46 AM
John Robotane
John Robotane - avatar
0
If the number is not even in range means print...
9th Apr 2020, 7:46 AM
SelvaKumar
0
to do so, if n%2 != 0 and n in range(2,5) and the second case if n%2 == 0 and n in range(6,20)
9th Apr 2020, 7:49 AM
John Robotane
John Robotane - avatar
0
but I think that your first elif condition should be elif n%2==0 and n in range(2,5) as the case n odd is already handled in the if statement.
9th Apr 2020, 7:53 AM
John Robotane
John Robotane - avatar
0
n = int(input()) if n%2!=0: print ("Weird") elif n%2==0 or n%2!=0 in range (2,5): print ("Not Weird") elif n%2==0 in range(6,20): print("Weird") elif n%2==0 and n>20: print ("Not Weird") ""When i give input 6 it shows Not Weird.. But it should print Weird... Still i don't get this 😣
9th Apr 2020, 8:03 AM
SelvaKumar
0
Last two statement is wrong i think so.. First statement is passed.. Other statements failed
9th Apr 2020, 8:04 AM
SelvaKumar
0
Thanks bro.. You saved me... It work's.....
9th Apr 2020, 8:07 AM
SelvaKumar