08-Sep-2022
.
Admin
Hi Dev,
This example is focused on python check if today is saturday or not example. In this article, we will implement a python check date is saturday or not. Here you will learn how to check if today is saturday in python. step by step explain check today is saturday in python. Alright, let’s dive into the steps.
In this example, we will use DateTime library to check whether today is Saturday 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 Saturday (0 = Mon, 1 = Tue, 2 = Wen ...)
if datetime.today().weekday() == 5:
print("Yes, Today is Saturday")
else:
print("Nope...")
Output:
Yes, Today is Saturday
Example 2:
main.py
from datetime import datetime
# If today is Saturday (1 = Mon, 2 = Tue, 3 = Wen ...)
if datetime.today().isoweekday() == 6:
print("Yes, Today is Saturday")
else:
print("Nope...")
Output:
Yes, Today is Saturday
I hope it can help you...
#Python