apartments = dict(living_room = ['sofa', 'coffee table', 'bookshelf', 'armchair'],
kitchen = ['stove', 'fridge', 'sink', 'shelves'],
bedroom = ['closet', 'bureau', 'bed', 'blinds', 'chest of drawers'],
bathroom = ['shower', 'bathtub', 'lavatory pan', 'shower cubicle'])
first_customer = ('I see you have a nice {}, you can sell to me that?'.format(*apartments['kitchen']))
print(first_customer)
我看你有一台漂亮的冰箱,你能卖给我吗
更新
如果我没弄错的话,这个就行了:
first_customer
应该初始化为一个列表,然后获取for循环(或上面的list comprehension)中的每个值,并将其格式化为字符串因此,如果要打印
kitchen
的第二个元素,请执行以下操作:相关问题 更多 >
编程相关推荐