Python Check if Today is Wednesday or not Example

05-Sep-2022

.

Admin

Python Check if Today is Wednesday or not Example

Hi Dev,

This is a short guide on Python Check if Today is Wednesday or not Example. This tutorial will give you simple example of Python Check Date is Wednesday or not. you will learn Check Today is Wednesday in Python. you will learn How To Check if 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:

So let's start with following examples with output:

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

#Python