python練習問題:トラフィックセット注文ウィジェット
2195 ワード
### u->user li->list prd->
prd_l1 = [
(' / ',5),
(' / ',10),
(' 10 10G',20),
(' 1G',10),
('30 5 G',30),
('50 50 G',50),
]
while 7:
u_shopping_li,u_mony =[],input(' :') # ,
if u_mony.isdigit(): #
u_mony = int(u_mony) #
[print(index, prd)for index,prd in enumerate(prd_l1)] #
while 1:
u_prds = input(" ( 'e' ):") #
if u_prds.isdigit(): #
u_prd = int(u_prds) #
if u_prd >= 0 and u_prd < len(prd_l1): # 0~5
prd, prd_mony = prd_l1[u_prd][0], prd_l1[u_prd][1] # ,
if u_mony >= prd_mony: #
u_shopping_li.append(prd) #
u_mony -= prd_mony
print(' , :%s , :%s .' % (prd, prd_mony, u_mony))
else:print(' , ! :%s ' % u_mony) #
else:print('NumbersError: !') # 0~5 ,
elif u_prds == 'e': # 'e'
if u_shopping_li != []:
print(' :')
[print(index, i) for index, i in enumerate(u_shopping_li)] #
print(' :%d ' % u_mony)
else: print(' , :%d ' % u_mony)
exit() #
else: print('TypeError: !') # 'e' ,
else: print(' : ')#