ice_cream = {'I Vanilla': [1.25, 10], 'I Chocolate': [1.25, 8], 'I Cookies & Cream': [1.51, 15]} #{ice cream type: price, quantity}
def show_inventory():
print('\nINVENTORY\n')
print('Ice Cream')
for key, value in ice_cream.items():
print("{:15} \t {:5} \t {}".format(key, *value))
这是我的结果
I Vanilla 1.25 10
I Chocolate 1.25 8
I Cookies & Cream 1.51 15
但是,我希望它看起来像这样......
1 ) I Vanilla 1.25 10
2 ) I Chocolate 1.25 8
3 ) I Cookies & Cream 1.51 15
4 ) future additions
5 ) future additions
答案 0 :(得分:0)
DyZ的意思是这个
ice_cream = {'I Vanilla': [1.25, 10], 'I Chocolate': [1.25, 8], 'I Cookies & Cream': [1.51, 15]} #{ice cream type: price, quantity}
def show_inventory():
print('\nINVENTORY\n')
print('Ice Cream')
for n, (key, value) in enumerate(ice_cream.items(), 1):
print("{}) {:15} \t {:5} \t {}".format(n, key, *value))