Commit cfe14104 by BellCodeEditor

auto save

parent 5e5ee02f
def abc(a,b): def new_input():
c=a+b total = []
return c while True:
s=abc(2,3) unit= input('请输入(q退出):')
print(s) if unit== 'q':
\ No newline at end of file break
else:
try:
unit=int(unit)
except:
print("输入错误,请重新输入一个数字")
else:
total.append(unit)
return total
list1=new_input()
def sum(money):
s=0
for i in money:
s+=i
return s
sss=sum(list1)
print(sss)
\ No newline at end of file
...@@ -11,5 +11,13 @@ def new_input(): ...@@ -11,5 +11,13 @@ def new_input():
print("请重新输入,要输入一个整数啊!") print("请重新输入,要输入一个整数啊!")
else: else:
total.append(unit) total.append(unit)
print(total) return total
new_input() # list1=new_input()
\ No newline at end of file # print(list1)
def sum(money):
count=0 #用来存储总价格
for i in money:
count+=i
return count
# s=sum(list1)
# print(s)
\ No newline at end of file
import func
data=func.new_input()
score=func.sum(data)
print(score)
\ 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