Programming Examples
Python program to create a dictionary whose keys are month names and values are their corresponding number of days
WAP to create a dictionary named year whose keys are month names and values are their corresponding number of days.
Solution
dict={}
ch='y'
while ch=='y' or ch=='Y':
month=input("Enter name of month : ")
days=eval(input("Enter no. of days of month : "))
dict[month]=days
ch=input("Want to add more months (Y/N) : ")
print(dict)
Output/ Explanation:
Enter name of month : january
ENter no. of days of month : 31
Want to add more months (Y/N) : y
Enter name of month : February
ENter no. of days of month : 28
Want to add more months (Y/N) : n
{'january': 31, 'February': 28}