Python Check if Today is Sunday or not Example

09-Sep-2022

.

Admin

Python Check if Today is Sunday or not Example

Hi Dev,

If you need to see example of Python Check if Today is Sunday or not Example. we will help you to give example of Python Check Date is Sunday. this example will help you Python Check Date is Sunday or not. you can see Check Today is Sunday in Python. You just need to some step to done How to Check if Today is Sunday in Python.

In this example, we will use DateTime library to check whether today is Sunday 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 Sunday (0 = Mon, 1 = Tue, 2 = Wen ...)

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

print("Yes, Today is Sunday")

else:

print("Nope...")

Output:

Yes, Today is Sunday

Example 2:

main.py

from datetime import datetime

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

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

print("Yes, Today is Sunday")

else:

print("Nope...")

Output:

Yes, Today is Sunday

#Python