Have a fairly simple program with a take a input for birthday which gives a day and month for birthday as a timedate object for example 19 May and have a dictionary with 12 keys aka January to December looking for a way to use a dictionary method to grab the value of the month inputted as a string and then converted to a timedate object.
#input birthday string
birthday = str(input("Please enter you birthday in the following format: dd/mm/yyyy."))
birthdate = datetime.strptime(birthday, "%d/%m/%Y") #formatting of input
birthdate2 = datetime.strftime(birthdate, "%d %B") #day and month object
print("Your birthday is on", birthdate2) #print the day and month object
#dictionary
famousBirthdays = {
"January": "Mozart",
"February": "Charles Darwin",
"March": "Albert Einstein",
"April": "Elizabeth II",
"May": "Linnaeus",
"June": "Josephine Baker",
"July": "Frida Kahlo",
"August": "Barack Obama",
"September": "Elizabeth I",
"October": "Gandhi",
"November": "Marie Curie",
"December": "Emily Dickinson"
}
Haven't tried much so far as very new to python and struggling to come up with any ideas best idea i came up with was isolate the month in a new timedate
object and write a statement to compare the two based on input and pull the corresponding value in the dictionary
but not sure where to start
Thanks for helping in the comments thanks, Bijay Regmi. Found a solution by adding an extra line to the timedate bit, a simpler way to handle it would prob be using number dates to simply things. Requirements constrained me, but an easy fix nonetheless is much appreciated.