Commit fed61f1b by BellCodeEditor

auto save

parent cb3617f6
Showing with 15 additions and 12 deletions
def new_input(): def new_input():
total = [] total = []
while True: while True:
unit= input("请输入:") unit = input("请输入:")
if unit== 'q': if unit == 'q':
break break
else: else:
try: try:
total.append(int(unit)) total.append(int(unit))
except: except:
print("请输入一个整数") print("请输入一个数字!")
return total return total
def sum(money): def sum(list1):
count = 0 sum = 0
for i in money: for i in list1:
count = count + i sum = sum + i
return count return sum
list1 = new_input()
s = sum(list1)
print('总共消费了:'+str(s) + '元')
a = new_input()
c = sum(a)
print(c)
\ 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