码迷,mamicode.com
首页 > 其他好文 > 详细

day2_作业1(购物车)

时间:2018-05-03 19:50:22      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:odi   opp   phone   hone   \n   ping   int   iphone x   you   

#!/usr/local/bin/python3
# -*- coding:utf-8 -*-

balance=int(input("Please input your salary:"))
Merchandise_list=[[1,‘Mac pro‘,16888],[2,‘Iphone x‘,7888],[3,‘Ps4 pro‘,4000]]
shopping_list=[]
while True:
    print(‘Merchandise list:\n‘)
    for x in Merchandise_list:
        print(x)
    num=input("which one do you want?-->")
    if num!=‘q‘:
        if balance>=Merchandise_list[int(num)-1][2]:
            balance-=Merchandise_list[int(num)-1][2]
            shopping_list.append(Merchandise_list[int(num)-1])
            print("your balance:",balance)
        else:
            print("your balance:",balance)
            print("your balance was inadequate!")
    else:
        print("your shopping list:", shopping_list)
        print("your balance:", balance)
        print("Looking forward to your next visit~")
        break

  

day2_作业1(购物车)

标签:odi   opp   phone   hone   \n   ping   int   iphone x   you   

原文地址:https://www.cnblogs.com/octopuszy/p/8986701.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!