Use the list and while to Build Shop car
#Author: Gordon
salary = int(input("请输入你的工资:"))
goods = [('0',"Iphone",5000),('1','Laptop',3500),('2','Coffee',20),('3','Chocolate',20)]
bought =[]
while True:
want = input("请输入要买的商品编号:")
if want.isdigit():
want = int(want)
if want > 0 and want < len(goods):
if salary > goods[want][2]:
bought.append(goods[want][1])
print(goods[want][1], "商品已经加入到你的购物车!")
salary = salary - goods[want][2]
print("你的余额还有:", salary)
else:
print("您的余额已经不足")
else:
print("对不起,我们没有这件物品")
elif want == 'q':
break
else:
print("这个无效的option")
print("你已经买了",bought)
print("你的余额是:",salary)
Use the list and while to Build Shop car的更多相关文章
- 在.NET 环境中实现每日构建(Daily Build)--ccnet,MSBuild篇(转载)
每日构建,对我们团队来说一个全新的概念.随着项目开发的进展,在开发过 程需要及时反馈一些BUG和功能要求的处理情况.而在这种情况下每天或隔一段时间Build一个版本,工作量还是比较大的,所以就特别有必 ...
- (转) Quick Guide to Build a Recommendation Engine in Python
本文转自:http://www.analyticsvidhya.com/blog/2016/06/quick-guide-build-recommendation-engine-python/ Int ...
- Microsoft .NET Pet Shop 4: Migrating an ASP.NET 1.1 Application to 2.0
249 out of 297 rated this helpful - Rate this topic Gregory Leake Microsoft Corporation Alan Le, Ale ...
- [springboot 开发单体web shop] 1. 前言介绍和环境搭建
前言介绍和环境搭建 简述 springboot 本身是为了做服务化用的,我们为什么要反其道使用它来开发一份单体web应用呢? 在我们现实的开发工作中,还有大量的业务系统使用的是单体应用,特别是对于中小 ...
- 解决 Springboot Unable to build Hibernate SessionFactory @Column命名不起作用
问题: Springboot启动报错: Caused by: org.springframework.beans.factory.BeanCreationException: Error creati ...
- [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform
eclipse maven clean install 报错 1. 修改properties-->resource-->utf-8仍然报错 2.修改项目pom.xml文件,增加: < ...
- 解决 Could not find com.android.tools.build:gradle 问题
今天拉同事最新的代码,编译时老是报如下错误: Error:Could not find com.android.tools.build:gradle:2.2.0.Searched in the fol ...
- 搭建TFS 2015 Build Agent环境(一)
Download the build agent Downloading the build agent is really simple. Navigate to your TFS control ...
- Go build constraints
Go语言有一个不(奇)错(葩)的设计,就是build constraints(构建约束).可以在源码中通过注释的方式指定编译选项,比如只允许在linux下,或者在386的平台上编译啊之类的:还可以通过 ...
随机推荐
- winform datagridview某一列设为自动宽度
如果用displayedcells只会使看见的数据自动列宽,滚动条往下发现后面的没有自动列宽,所以要用allcells就不会出现这个问题
- C# Winform下一个热插拔的MIS/MRP/ERP框架(通用控件)
一直对商业控件不感冒, 结合日常工作, 我写了几个常用控件. 一.下拉框控件(仿Access下拉框:F4下拉,自动输入,支持单/多列显示),可在Datagridview中使用. 1.常规: 2.Dat ...
- luoguP4234 最小差值生成树
https://www.luogu.org/problemnew/show/P4234 按照边的权值从小到大排序,依次加入,并删除能够删除的权值最小的一条边,用 set 维护当前所有边的边权,并查集维 ...
- MongoDB集群配置笔记
firewall-cmd --query-port=27017/tcp yum install system-config-firewall-tui firewall-cmd --zone=publi ...
- string[] 转换为 int[]
string[] ke=...... int[] output = Array.ConvertAll<string, int>(ke,delegate (string s) { retur ...
- ThinkCMF if 标签
用法示例: <if condition="($name eq 1) OR ($name gt 100) "> value1 <elseif condition=& ...
- python学习之路---day21--模块和栈
模块和栈 一:计数模块collections 基础版本: s="qwewsfdfjiehrfqweqweqwqewq" dic={} for el in s: dic[el]=di ...
- Android ToggleButton(开关函数)与switch (开关按钮)
1.ToggleButton (1)介绍 (2)组件形状 (3)xml文件设置 <?xml version="1.0" encoding="utf-8"? ...
- POJ2449 Remmarguts' Date A*算法
题意是让求从st的ed第k短路... 考虑A*算法:先把终点到每个点最短路跑出来(注意要建反图),当做估价函数h(u),然后跑A* 每次取出总代价最小的,即g(u)+h(u)最小的进行扩展,注意如果u ...
- P3243 [HNOI2015]菜肴制作
传送门 把时间看成数,菜肴看成位置 考虑一个位置填什么数很麻烦 考虑一个数放在什么位置 一开始我想的是,对于一个限制 $(a,b)$ ,从 $a$ 往 $b$ 连一条边,然后如果有解则所有的限制构成了 ...