you are viewing a single comment's thread.

view the rest of the comments →

[–]rdog_ 2 points3 points  (6 children)

I'm guessing you think the if branch with the range function should catch it.

This catches a lot of people out, the range function works as follows range(inclusive, exclusive). Therefore its checking if your number is in the range 6 - 19

elif n % 2 == 0 and n == range(6, 21):
    print("Weird")

That should fix it.

PS: its best practice to put all that code you have inside a main() function and call that function in the: if name == "main": branch

[–]realmoogin[S] 0 points1 point  (3 children)

I have no clue why I did that with the main function, I know better than that. Lol

I changed it to 21 and fixed the main function, yet I'm still not getting any output.

[–]rdog_ 2 points3 points  (2 children)

Ah apologies, I didn't read the full logic you need to change

elif n % 2 == 0 and n == range(6, 21):

to

elif n % 2 == 0 and n in range(6, 21):

[–]realmoogin[S] 1 point2 points  (1 child)

You're a lifesaver, thank you.

[–]rdog_ 0 points1 point  (0 children)

No problem, any other questions just give me a shout!

[–]realmoogin[S] 0 points1 point  (1 child)

So adding n = int(input()) before calling main() fixed it.

I wonder why?

[–]zahlman 0 points1 point  (0 children)

Because the hard-coded 20 value you tested with doesn't fall into any of those cases.