Commit 0cd59831 by BellCodeEditor

auto save

parent 68714a28
Showing with 10 additions and 9 deletions
food = {"可口可乐":4,"辣条":3,"薯片":12} food = {"可口可乐":4,"辣条":3,"薯片":12}
#1.输入名字和价格 #1.通过input输入我们想要的商品 赋值给一个变量f 键
#2.判断商品是否在字典中 f = input('请输入商品名')
#3.判断新商品和原本字典中的商品哪个更便宜 #2.判断你的售货机里是否有这件商品 (判断 f 在 food)
#4.便宜就修改字典的值 if f in food:
#5.否则就输出太贵了 print(f+str(food[f]))
#3.在的话,就输出他的价格
else:
#6.如果不在就添加进字典中,并输出 print('无货')
\ No newline at end of file #4.否则就输出没有货
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment