+ 1

Is it possible to have multiple and/or statements in one if statement? The code says the last "and" is an invalid syntax

if day >=20 <=31 and month ==1 or day >=1<=18 and month==2 print("Aquarius")

23rd May 2022, 2:13 PM
Zanele
Zanele - avatar
3 odpowiedzi
+ 1
yes. but you have wrong syntax. For Between : correct syntax is 20 <= day <= 31 # day between 20 and 31 1 <= day <= 18 # both end values inclusive edit: if ( 20 <= day <=31 and month ==1 ) or ( 1 <= day <=18 and month==2 ) : print("Aquarius")
23rd May 2022, 2:17 PM
Jayakrishna 🇮🇳
+ 1
Thank you
23rd May 2022, 3:05 PM
Zanele
Zanele - avatar
0
You may need to use parentheses to group together statements.
23rd May 2022, 2:17 PM
Justice
Justice - avatar