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}
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad