Python Check if Today is Friday or not Example

07-Sep-2022

.

Admin

Python Check if Today is Friday or not Example

Hi Dev,

In this example, I will show you Python Check if Today is Friday or not Example. This tutorial will give you simple example of how to check if today is friday in python. I explained simply step by step python today is friday. you will learn how to check if today is friday in python.

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

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

print("Yes, Today is Friday")

else:

print("Nope...")

Output:

Yes, Today is Friday

Example 2:

main.py

from datetime import datetime

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

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

print("Yes, Today is Friday")

else:

print("Nope...")

Output:

Yes, Today is Friday

I hope it can help you...

#Python