[{'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}, {'January': 'Sun'}]
Thats my dict.
My code to make a list of values of dict_month
dict_month = []
jan_month= []
for x in file_st:
a=calendar.month_name[int(x['Start Time'][5:7])] #month name
b=parser.parse(x['Start Time']).strftime("%a") # day name
dict_month.append({a:b}) # [{}]
for x in dict_month:
jan_month.append(x['January'])
The error i get is
KeyError Traceback (most recent call
last)
<ipython-input-42-879788f99587> in <module>()
23
24 for x in dict_month:
---> 25 jan_month.append(x['January'])
26
KeyError: 'January'
Where is the code wrong? how do i correct it?
output [sun,sun,sun]
edit its a key error this should help.