Python Check if Today is Monday or not Example

01-Sep-2022

.

Admin

Python Check if Today is Monday or not Example

Hi Dev,

This post is focused on Python Check if Today is Monday or not Example. you can see Python Check Date is Monday or Not. Here you will learn Check Today is Monday in Python. This article will give you simple example of Python Today is Monday.

In this example, we will use DateTime library to check whether today is Monday or not. I will give you two simple examples one using weekday() and another using isoweekday(). so let's see both examples:

so let's see following examples with output:

Example 1:


main.py

from datetime import datetime

# If today is Monday (0 = Mon, 1 = Tue, 2 = Wen ...)

if datetime.today().weekday() == 0:

print("Yes, Today is Monday")

else:

print("Nope...")

Output:

Yes, Today is Monday

Example 2:

main.py

from datetime import datetime

# If today is Monday (1 = Mon, 2 = Tue, 3 = Wen ...)

if datetime.today().isoweekday() == 1:

print("Yes, Today is Monday")

else:

print("Nope...")

Output:

Yes, Today is Monday

#Python