完成代码以遍历 car_prices 字典的键和值,打印出关于每个键和值的一些信息

新手上路,请多包涵

填写空白,以便代码给出输出。

 def car_listing(car_prices):
    result = ""
    for __:  #fill this
        result += "{} costs {} dollars".__ + "\n"  # fill this
    return result

print(car_listing({"Kia Soul":19000, "Lamborghini Diablo":55000,
"Ford Fiesta":13000, "Toyota Prius":24000}))

原文由 Lamda Function 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 271
1 个回答
def car_listing(car_prices):
  result = ""
  for name, price in car_prices.items():
    result += "{} costs {} dollars".format(name, price)+ "\n"
  return result

原文由 JY Lim 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进