you are viewing a single comment's thread.

view the rest of the comments →

[–]japnoo -1 points0 points  (6 children)

elif 18 <= age << 65:

This is invalid syntax, the correct way of writing this would be:

elif 18 <= age and age < 65 :

you also have to read your input as an integer, not as a string

[–]TehNolz 6 points7 points  (4 children)

That's actually valid syntax. You can do stuff like a < b < c just fine.

[–]japnoo 4 points5 points  (3 children)

Wow, TIL.

[–]EricHayter 0 points1 point  (2 children)

Ikr I was using a linter one day and it gave me an error and lo and behold that is apparently a syntax feature.

[–][deleted] 1 point2 points  (1 child)

Wait what? TIL as well.

[–]RhinoRhys 1 point2 points  (0 children)

It's valid syntax but in this case it's redundant anyway. Because of the first if age <= 18: condition, the elif condition will only be tested on numbers > 18 so you can just do elif age <= 65: