繼續從以前的真棒幫助,我現在有異常處理的問題。 我有11個地塊的索引號被選中。如果用戶選擇高於11,它應該請求他們重新輸入但atm,我得到IndexError:列表索引超出範圍。 我會認爲除了行會處理其他任何東西......但它必須是一個缺失的行?IndexError ...超出範圍,
try:
response = raw_input("Select a monitoring plot from the list (0-11): ")
if response == 'q':
confirm = raw_input('Confirm quit (y/ n)...')
if confirm == 'y':
print 'Bye'
break
else:
continue
selected = dataList[int(plotSelect) + 1]
print 'You selected : ', selected[1]
except ValueError:
print "Error: Please enter a number between 0 and 11"
那是什麼'plotSelect'?它應該是'response'? – Cairnarvon 2013-04-21 03:37:36