How to Check if Today is Wednesday or not in Python?

By Hardik Savani October 30, 2023 Category : Python

In this post, we will learn python check date is wednesday. I explained simply step by step how to check if today is wednesday in python. step by step explain how to check if today is wednesday in python. I would like to show you python today is wednesday. Here, Creating a basic example of check today is wednesday in python.

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

You can use these examples with python3 (Python 3) version.

Example 1:

main.py

from datetime import datetime
  
# If today is Wednesday (0 = Mon, 1 = Tue, 2 = Wen ...)
if datetime.today().weekday() == 2:
    print("Yes, Today is Wednesday")
else:
    print("Nope...")

Output:

Yes, Today is Wednesday

Example 2:

main.py

from datetime import datetime
  
# If today is Wednesday (1 = Mon, 2 = Tue, 3 = Wen ...)
if datetime.today().isoweekday() == 3:
    print("Yes, Today is Wednesday")
else:
    print("Nope...")

Output:

 
Yes, Today is Wednesday

I hope it can help you...

Tags :
Shares