0
Syntax error
Can someone explain why the <= is invalid in the following code: year = int(input("enter birth year")) if year >= 1983 and <= 2000: print("You're a millenial'") else: print("Oldie but goodie")
3 Answers
+ 14
if year >= 1983 and year <= 2000:
or
if 1983 <= year <= 2000:
+ 3
Mert Yazıcı Thanks for mentioning both; I totally didn't realize the comparisons / inequality tests could be chained like that.
ref: https://docs.python.org/3/reference/expressions.html#comparisons
"Comparisons can be chained arbitrarily..."
0
Ah rookie mistake, thanks Mert Yazici!
Hot today
Python — File Handling
0 Votes
Loop question, I've tried everything that I knew I just don't know. Please help me solve it out
1 Votes
Help me solve this (using loop)
1 Votes
What is wrong? Error on test.
1 Votes
Help me wiht python
1 Votes
?
0 Votes