Q:
Write a program called birthday_021.py that reads lines of text. where each line consists of a person’s date of birth. A date of birth is specified by three integers: a day, a month and a year. The program should determine on which day of the week each person was born and print the corresponding line from the poem:
Monday’s child is fair of face Tuesday’s child is full of grace
Wednesday’s child is full of woe Thursday’s child has far to go
Friday’s child is loving and giving Saturday’s child works hard for a
living Sunday’s child is fair and wise and good in every way For
My code:
#!/usr/bin/env python3
import datetime
import calendar
def findDay(date):
born = datetime.datetime.strptime(date, '%d %m %Y').weekday()
return (calendar.day_name[born])
date = '26 11 2001'
print("You were born on a " + findDay(date))
My problem:
In the code I posted above it prints "you were born a Friday".
The problem is I Don't know how to add the poem line for Friday to the output. My answer should be "you were born on a Friday and Friday's child is loving and giving"
dictionary
with key as weekday?"Monday"
,"Tuesday"
, etc and values - the corresponding poem lines. Then add to printyour_dicitonary[findDay(date)]