Commit af16640d by BellCodeEditor

save project

parent 29241d6b
Showing with 11 additions and 10 deletions
...@@ -5,18 +5,19 @@ def new_input(): ...@@ -5,18 +5,19 @@ def new_input():
try: try:
unit=int(unit) unit=int(unit)
except: except:
total.append(unit)
else:
if unit== 'q': if unit== 'q':
break break
else: else:
print('输入错误,请重新输入一个数字') print('输入错误,请重新输入一个数字')
else:
total.append(unit)
return total return total
def sum(m): def sum(m):
for i in total: a=0
m=m+i for i in m:
return sum(m) a=a+i
new_input() return a
a=sum(m) l=new_input()
print(a) print(l)
print("您一共消费了"+a+'元!') print(sum(l))
\ No newline at end of file print("您一共消费了"+str(sum(l))+'元!')
\ 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