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 Respuestas
+ 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!