product_list=[
(‘iphone‘,5000),
(‘car‘,500400),
(‘book‘,50),
(‘bicycle‘,500),
(‘computer‘,22200),
]
shop_car=[]
user_name="liuxi"
login_password=1763335968
input_name=input("plese import you id:")
input_password=int(input(‘plese import you password:‘))
if input_name == user_name and input_password ==login_password:
wallet=input(‘plese fill down how much money you have:‘)
if wallet . isdigit() :
wallet=int(wallet)
while True:
for i,c in enumerate(product_list,1):
print(i,c)
choise_shop=input(‘which goods you want [quir:q]:‘)
if choise_shop .isdigit():
choise_shop=int(choise_shop)
if choise_shop<= len(product_list):
pick_shop=product_list[choise_shop-1]
else :
print("plese fill number one to " ,len(product_list))
if wallet > pick_shop[1]:
wallet -=pick_shop[1]
shop_car.append(pick_shop[0])
else :
print(‘you wallet not enough plese try cheaper goods‘)
elif choise_shop == ‘q‘:
print(‘you will quit ‘)
print(‘------you have buy these comdity----- ‘)
for s in shop_car:
print(s)
print(‘you wallet remain %s yuan ‘%wallet)
break
else :
print(‘plese fill right format‘)
else:
print(‘plese fill ture number‘)
else :
print(‘plese import ture id or password‘)
原文:https://www.cnblogs.com/CIBud/p/11377476.html