我正在学习python.它在此脚本中提供语法错误.我无法弄明白.
import exceptions
class FOUND(Exception): pass
x = [1,2,3,4,56,73,29,35,12,32,63,12,76,75,89]
while True:
try:
test = int(raw_input('Enter integer to be checked in list:'))
count = -1
for y in x:
count += 1
if y == test:
raise FOUND
except ValueError as e:
print "Not a valid integer (%s)"%(e)
except FOUND:
print "Found (%d) at (%d)"%(test,count)
else:
print "Not found ,Appending (%d) to list at location (%d)"%(test,count+1)
x.append(test)
finally:
print "The List:"
print x
print " "
Run Code Online (Sandbox Code Playgroud)
语法无效,并突出显示此行中的结束双引号: print "Not a valid integer (%s)"%(e)
| 归档时间: |
|
| 查看次数: |
6968 次 |
| 最近记录: |