标题我也不知道写啥
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了标题我也不知道写啥相关的知识,希望对你有一定的参考价值。
1 li = ["手机","电脑","鼠标垫","游艇"]
2 for i,j in enumerate(li):
3 print(i+1,j)
4 num= input("num:")
5 num = int(num)
6 len_li = len(li)
7 if num >0 and num < len_li:
8
9 good = li[num-1]
10 print(good)
11 else:
12 print("商品不存在")
--------------分割线-----------------
1 asset_all = 1999
2 car_list = []
3
4
5 i1 = input(‘请输入总资产:‘)
6 asset_all = int(i1)
7
8 goods = [
9 {"name":"电脑","price":1999},
10 {"name":"鼠标","price":10},
11 {"name":"游艇","price":20},
12 {"name":"美女","price":998},
13 ]
14
15 for i in goods:
16 print(i[‘name‘],i[‘price‘])
17
18 while True:
19 i2 = input(‘请输入商品:‘)
20 if i2 == "y":
21 break
22 for j in goods:
23 if j [‘name‘] == i2:
24 car_list.append(j)
25
26 print(car_list)
27 all_price = 0
28 for item in car_list:
29 p = item[‘price‘]
30 all_price = all_price + p
31 print(asset_all,all_price)
32 if all_price > asset_all:
33 print(‘你个穷逼‘)
34 else:
35 print("购买成功")
以上是关于标题我也不知道写啥的主要内容,如果未能解决你的问题,请参考以下文章