Commit d9001b5c by BellCodeEditor

save project

parent 5fcf8d0e
Showing with 18 additions and 6 deletions
def price(): def price():
total = [] total = []
while True: while True:
unit = input("请输入:") unit = input("请输入:(输入“q”退出)")
if unit == 'q': if unit == 'q':
break break
else: else:
try:
unit = int(unit)
except:
print('输入错误,请输入数字!')
else:
total.append(unit) total.append(unit)
print('*'*30) return total
print(total)
print(' '*30) def sum(alist):
count = 0
for i in alist:
count += i
return count
price() p = price()
\ No newline at end of file print(p)
s = sum(p)
print(s)
\ 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