Commit 7e6e6e4c by BellCodeEditor

auto save

parent 05e7d622
def a():
total = []
while True:
unit=input("请输入:")
#赋值unit
if unit == 'q':
break
else:
try:
unit == int(unit)
#如果unit是整数
except:
print("请输入整数")
#报错后的程序
else:
total.append(int(unit))
print("已添加")
#如果程序不报错
print(total)
return total
def d(xyz):
e=0
for i in xyz:
e=e+i
return e
c=a()
f=d(c)
# print('一共消费'+str(f)+'元')
\ No newline at end of file
import func
c=func.a()
f=func.d(c)
print('总数为'+str(f))
\ 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