How to Check if Today is Sunday or not in Python?
Now, let's see tutorial of python check date is sunday. In this article, we will implement a how to check if today is sunday in python. you will learn how to check if today is sunday in python. We will look at example of python today is sunday.
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:
You can use these examples with python3 (Python 3) version.
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
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Check if Today is Friday or not in Python?
- How to Check if Today is Thursday or not in Python?
- How to Check if Today is Wednesday or not in Python?
- How to Check if Today is Tuesday or not in Python?
- How to Check if Today is Monday or not in Python?
- Python Check if Date is Weekend or Weekday Example
- Python Subtract Seconds from DateTime Example