Commit dbcb829b by BellCodeEditor

auto save

parent 578e41ee
def m(ab):
cont=0
for i in ab:
cont+=i
return cont
print(m([1,2,3,4,5]))
print(sum([1,2,3,4,5])) #sum()求一个数字序列中所有数字的和
\ No newline at end of file
import ab
total = [] #封装成price()函数
while True: def price():
total = []
while True:
unit= input("请输入:") unit= input("请输入:")
if unit== 'q': if unit== 'q':
break break
else: else:
try:
unit = int(unit)
except:
print('请输入整数')
else:
total.append(unit) total.append(unit)
print(total) return total
\ No newline at end of file #print(sum(price()))
\ 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