n = int(input())
s = 0
while True:
try:
for i in range(1, n):
if n % i == 0:
s += i
if s > n:
print('盈數')
elif s == n:
print('完全數')
elif s < n:
print('虧數')
except:
break
n = int(input())
s = 0
while True:
try:
for i in range(1, n):
if n % i == 0:
s += i
if s > n:
print('盈數')
elif s == n:
print('完全數')
elif s < n:
print('虧數')
except:
break
while True:
try:
n = int(input())
s = 0
for i in range(1, n):
if n % i == 0:
s += i
if s > n:
print('盈數')
elif s == n:
print('完全數')
elif s < n:
print('虧數')
except:
break
from sys import stdin
for line in stdin:
print(line, end='')
不要再用 While True 搭配 try except 查一下網路很難嗎
https://stackoverflow.com/questions/21235855/how-to-read-user-input-until-eof