In: Computer Science
create a python program that ask for a name and birth year separated by a comma. the program should keep prompting until the user inputs 'quit'.
print the dictionary containing the key value pair name:year in the same order they were inputted.
print the name and birth year on a single line for each of the entries.
finally print the dictionary with the key value paris swapped and sorted by birth year. from youngest to oldeest.
dataDict={}
while(True):
data=input("Name and year with comma:")
data=data.split(",")
if(data[0]=='quit'):
break
else:
dataDict[data[0]]=int(data[1])
print(dataDict)
for key,value in dataDict.items():
print("{} {}".format(key,value))
sort_Dict={key:value for key, value in sorted(dataDict.items(),reverse=True,key=lambda datai: datai[1] )}
print(sort_Dict)