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

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}
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad