+ 1
PLEASE NEED A CORRECTION IN CODE!!!!!
Q. Create a dictionary whose keys are month name and whose values are number of days in the corresponding month: (a) Ask the user to enter the month name and use the dictionary to tell how many days are in month. (b) Print out all of the keys in alphabetical order. (c) Print out all of the month with 31 days. d = {'January':31,'February':28,'March':31,'April':30,'May':31,'June':30,'July':31,'August':31,'September':30,'October':31,'November':30,'December':31} mname= input("Enter month's name:") x=d[mname] print(mname,x) print('Keys in alphabetical order:',sorted(d)) y = d.keys() print('List',y) z=[] for a in range(len(y)): if a%2==0: z+=y[a] print('Months with 31 days:',z)
2 ответов
+ 2
[k for k,v in d.items() if v==31]
+ 3
People are more likely to test your code if you LINK it instead of pasting it into the description.
Go to Code section, click +, select the programming language, insert your code, save.
Come back to the thread, click +, Insert Code, sort for My Code Bits, select your code.