Python elif Statement with OR Operator in Condition/Expression – Example code

Python elif Statement with OR Operator using combines two basic conditional expressions in a Boolean expression.

Checking weekday and weekend string in if statement.

today = 'Sunday'

if today == 'Monday':
    print('Your weekend is over. Go to work.')
    
elif today == 'Sunday' or today == 'Saturday':
    print('Today is off.')
else:
    print('Go to work.')

Output:

Python elif Statement with OR Operator in Condition

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.