Syntax error What is weekday() method in python?

What is weekday() method in python?



The weekday() method is used to returns the particular day of the week.

Example

import datetime
import calendar
#defining function named called findweekDay
def findWeekDay(date):
i = datetime.datetime.strptime(date, '%d %m %Y').weekday()
return (calendar.day_name[i])

date = '24 05 2019'
print(findWeekDay(date))

Output

friday
Updated on: 2019-07-30T22:30:26+05:30

195 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements