-1

I tried these variations, but didn't succeed:

print calendar.monthcalendar(z,y)

print datetime.date(y,x,z).weekday()

print datetime.date(y,x,z).strftime('%A')
Mike P
  • 742
  • 11
  • 26
Nikhil Kadam
  • 65
  • 1
  • 1
  • 8

2 Answers2

1

You have to convert user input (s in the example below) to a datetime object. Then you can utilize strftime to print the day of the week:

>>> import datetime
>>> s = "11.05.2015"
>>> d = datetime.datetime.strptime(s, "%d.%m.%Y")
>>> d
datetime.datetime(2015, 5, 11, 0, 0)
>>> d.strftime("%A")
'Monday'
Andy
  • 49,085
  • 60
  • 166
  • 233
0

You can create a time object from the time module and then grab the weekday from calendar:

calendar.day_name[time.strptime('11.05.2015', '%d.%m.%Y').tm_wday]
Malik Brahimi
  • 16,341
  • 7
  • 39
  • 70