Commit e9e98925 by BellCodeEditor

save project

parent 2e08678e
Showing with 16 additions and 7 deletions
...@@ -6,9 +6,13 @@ def new_input(): ...@@ -6,9 +6,13 @@ def new_input():
if a== 'q': if a== 'q':
break break
else: else:
total.append(a) try:
for i in total: a = int(a)
sum+=int(i) except:
print("要输入数字啊!")
else:
total.append(a)
sum += a
print(total) print(total)
print(sum) print(sum)
new_input() new_input()
\ No newline at end of file
...@@ -6,8 +6,13 @@ def new_input(): ...@@ -6,8 +6,13 @@ def new_input():
if unit=='q': if unit=='q':
break break
else: else:
total.append(unit) try:
sum += int(unit) unit=int(unit)
except:
print("输整数!")
else:
total.append(unit)
sum += unit
print(total) print(total)
print(sum) print(sum)
new_input() new_input()
\ 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