У меня есть такая ситуация, когда мне нужно выбрать слово, чтобы программа выводила значение слова, но номер заказа не соответствует номеру индекса x, пример (1,2,3), но индексы (0, 3,7), и в следующий раз это может быть (1,2,3) и индекс (1,3,5), не могли бы вы помочь, как я могу решить эту проблему.Я хочу любое решение, если выбрать второе слово, я хочу его значение.спасибо с уважением umer selmani
empt_list=[]
empt_list_meaning=[]
def game():
empt_dict = dict(zip(empt_list, empt_list_meaning))
a_options = input("Please select one of these options: ")
if a_options == 1:
a_newword = str(raw_input("What word you want to add? "))
empt_list.append(a_newword)
a_newword_meaning=str(raw_input("add the meaning of the word: "))
empt_list_meaning.append(a_newword_meaning)
elif a_options == 2:
a_select_word = raw_input("select the words, you want")
zero = 0
for word in empt_dict:
if a_select_word in word:
zero += 1
print zero, word,
print empt_dict.keys().index(word)
print ("would you like to continue or exit?\n1.contine\n2.exit")
now = input(">>> ")
if now == 1:
game()
else:
print "bye"
game()
здесь, выходной.
"C:\Users\Umer Selmani\venv\Scripts\python.exe" "C:/Users/Umer Selmani/.PyCharm2017.3/config/scratches/scratch_10.py"
Please select one of these options: 1
What word you want to add? ball
add the meaning of the word: round shape item
would you like to continue or exit?
1.contine
2.exit
>>> 1
Please select one of these options: 1
What word you want to add? cactus
add the meaning of the word: flower type
would you like to continue or exit?
1.contine
2.exit
>>> 1
Please select one of these options: 1
What word you want to add? fall
add the meaning of the word: season
would you like to continue or exit?
1.contine
2.exit
>>> 1
Please select one of these options: 2
select the words, you wantll
1 ball 0
2 fall 2
would you like to continue or exit?
1.contine
2.exit
>>> 2
bye