-3
我試圖讓那一個用戶輸入相匹配的應用程序,並顯示百分比它是屬於(預定義的句子)指數錯誤:列表分配索引超出範圍
store_word=""
def client_query_function():
point =0
i=0
z=0 #tells the index number of the sentence
p=""
global store_word
client_query = raw_input(">> ")
len_client_query=len(client_query)
i=len_client_query
for z in range(i):
#print client_query[z]
if client_query[z]!=" ":
p=p+client_query[z]
store_word=""
else:
store_word=p
print "store_word" ,store_word
#dictonary search
timeis =[]
dateis = []
client_query_function()
def timeis_funct(store_word):
global pm_timeis
timeis[5]=["what","is","the","time","?",""]
for i in range (len(timeis)):
if store_word==timeis[i]:
pm_timeis=pm_timeis+1
else:
continue
return pm_timeis
def dateis_funct(store_word):
global pm_dateis
dateis[5]=["what","is","the","date","?",""]
for i in range (len(dateis)):
if store_word==dateis[i]:
pm_dateis=pm_dateis+1
else:
continue
return pm_dateis
def percent_cal():
timeis_funct(store_word)
dateis_funct(store_word)
percent_cal()
這句話在運行程序的顯示列表分配索引超出範圍,這不應該發生
追溯請嗎? –
提供有關發生的錯誤的更多信息。它發生在哪一行? –
我假設這個錯誤發生在「timeis [5] = [」what「,」is「,」the「,」time「,」?「,」「]」行,對不對? – rayray84