Using both OR, AND in an IF-statement - Python
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Quiet Intelligence
--
Chapters
00:00 Using Both Or, And In An If-Statement - Python
00:26 Accepted Answer Score 20
00:44 Answer 2 Score 0
00:54 Thank you
--
Full question
https://stackoverflow.com/questions/7276...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python
#avk47
    Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Quiet Intelligence
--
Chapters
00:00 Using Both Or, And In An If-Statement - Python
00:26 Accepted Answer Score 20
00:44 Answer 2 Score 0
00:54 Thank you
--
Full question
https://stackoverflow.com/questions/7276...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python
#avk47
ACCEPTED ANSWER
Score 20
In Python and binds tighter than or. So your statement is equivalent to this:
if day == 0 or (day == 6 and vacation != True):
To get the correct result you must parenthesize the precedence yourself:
if (day == 0 or day == 6) and vacation != True:
ANSWER 2
Score 0
What you probably want is this:
def alarm_clock(day, vacation):
    if (day == 0 or day == 6) and vacation != True:
        return "10.00"
    else: 
        return "off"
print(alarm_clock(0, True))