Commit e3729368 by BellCodeEditor

auto save

parent c20b6490
def num():
def num():
total = []
print('按下q退出')
while True:
player=input('输入价格:')
if player=='q':
break
else:
try:
player=int(player)
except:
print('请重新输入')
else:
total.append(player)
return total
def sum(money):
count=0 #计算总和
for i in money:
count+=i
return count
# print('一共消费'+str(pay)+'元')
def diancan(): #创建函数 def diancan():
def diancan(): #创建函数 def diancan():
total = [] total = []
while True: while True:
unit= input("请输入:") unit= input("请输入:")
...@@ -18,6 +18,6 @@ def sum(money): ...@@ -18,6 +18,6 @@ def sum(money):
for i in money: for i in money:
count = count + i count = count + i
return count return count
a=diancan()#使用函数 q=diancan()
b=sum(a) w=sum(q)
print(b) print(w)
\ No newline at end of file
import 函数返回1
import 函数返回1
a=函数返回1.num()
b=函数返回1.sum(a)
print('一共消费'+str(b)+'元')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment