Commit 0209aa6e by BellCodeEditor

save project

parent 7bd39b0c
Showing with 8 additions and 5 deletions
...@@ -2,14 +2,17 @@ def func(): ...@@ -2,14 +2,17 @@ def func():
total = [] total = []
while True: while True:
unit= input("请输入:") unit= input("请输入:")
try:
unit1= int(unit)
except
if unit== 'q': if unit== 'q':
print("结束") print("结束")
break break
try:
unit1= int(unit)
except:
print("要输入整数") print("要输入整数")
continue continue
else: else:
total.append(unit) total.append(unit)
print(total) return total
\ No newline at end of file
r = func()
print(r)
\ 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