Just change your function command_show()to this, if you are not using dict.items(), then you will only get the keys (not both keys and values):
def command_show(calendar):
for (date, event) in calendar.items():
print(date+':')
for i in enumerate(event):
print(' '+str(i[0])+': '+i[1])
Output:
2015-10-29:
0: Python class
1: Change oil in blue car
2015-10-12:
0: Eye doctor
1: lunch with sid
About why I do this:
for i in enumerate(event):
print(' '+str(i[0])+': '+i[1])
As you can see, I use enumerate()here. From the doc:
. iterable , , .
__next__() , enumerate(), , ( , 0), , iterable.
, - [(0, 'Python class'), (1, 'Eye doctor'), (2, 'lunch with sid')], evernt - ['Python class', 'Eye doctor', 'lunch with sid'].
[(0, 'Python class'), (1, 'Eye doctor'), (2, 'lunch with sid')], for , for i in enumerate(event), i (0, 'Python class') , (1, 'Eye doctor') ..
, - 0: Python class ( ), , ' '+ (+ , , 'foo'+'bar' - foobar).
, i , slice. i[0] , i[1] ..
i[0] , - 0 + 'foobar' ( TypeError: unsupported operand type(s) for +: 'int' and 'str'). str(), . ... , .
- :
for num, event in enumerate(event):
print(' '+str(num), event, sep=': ')
? for num, event in enumerate(event) - num = 0, evert = 'Python class' ... .
sep .