Commit 5e03c493 by BellCodeEditor

auto save

parent 81082ce5
import func
func.new_input()
\ No newline at end of file
...@@ -5,7 +5,27 @@ def new_input(): ...@@ -5,7 +5,27 @@ def new_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) finally:
print("-"*30)
return total
result = new_input()
print(result)
#计算总和
sum = 0
def sum_total(x):
sum = 0
for i in result:
sum = sum + i
return sum
sum = sum_total(result)
new_input() print('总价钱' + str(sum))
\ 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