I have started learning python. In this code, I am trying to print the Birthdate of the inputted user along with his/her name. I am using a dictionary to achieve this functionality. Below is my code snippet
n=input("Enter Name: ")
def birth():
dict1={{"name":"X","birthdate":"16-June-1989"},{"name":"Y","birthdate":"23-08-1990"}}
if dict1["name"]==n:
print(dict1["name"]+"'s birth was on " +dict1["birthdate"])
else:
print("Not in database")
birth()
My expected output should look like this on inputting X:
X's birthdate was on 16-June-1989
But I am getting below error, I tried an online search, but I wanted to understand what I am missing here. I am sure I will be getting many comments. But I am also sure that many will provide constructively and learning suggestions.
File "main.py", line 8, in <module>
birth()
File "main.py", line 3, in birth
dict1={{"name":"X","birthdate":"16-June-1989"},{"name":"Y","birthdate":"23-08-1990"}}
TypeError: unhashable type: 'dict'