Skip to content

Instantly share code, notes, and snippets.

@roman-on
Last active April 9, 2020 16:43
Show Gist options
  • Save roman-on/6bb97ba4599791432d9e0a5decca5849 to your computer and use it in GitHub Desktop.
Save roman-on/6bb97ba4599791432d9e0a5decca5849 to your computer and use it in GitHub Desktop.
Calendar
"""
Write a program that gets the user a date in dd / mm / yyyy format and prints the day of the week for the entered date.
dd/mm/yyyy
calendar , weekday
"""
import calendar
cale = input("Enter a date dd/mm/yyyy:")
# 15/05/2016
a = cale.replace("/", "")
# >>> 15052016
ye = int(a[-4:])
mon = int(a[-6:-4])
da = int(a[:-6])
day_num = calendar.weekday(ye, mon, da)
if day_num == 0:
print("Monday")
elif day_num == 1:
print("Tuesday")
elif day_num == 2:
print("Wednesday")
elif day_num == 3:
print("Thursday")
elif day_num == 4:
print("Friday")
elif day_num == 5:
print("Saturday")
else:
print("Sunday")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment