-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