Commit c8c5e348 by BellCodeEditor

auto save

parent 6d226cff
Showing with 20 additions and 15 deletions
...@@ -6,21 +6,26 @@ ...@@ -6,21 +6,26 @@
# else: # else:
# total.append(unit) # total.append(unit)
# print(total) # print(total)
total = [] def new_input():
while True: total = []
try: while True:
unit = int(print("请输入价格:")) unit = input("请输入菜品价格:")
if unit == "q": if unit == "q":
break break
else:
except: try:
unit = int(unit)
except:
print("请输入数字奥") print("请输入整数奥")
else: else:
total.append(unit)
total.anpped(unit)
print(total) print(total)
return total
result = new_input()
sum = 0
for i in range(len(result)):
sum = sum + result[i]
print("result的值为",result)
print(sum)
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