为什么这个程序没有将 'None' 字符串添加到所需的键?

Why does this program doesn't add the 'None' string to the desired key when it should?

在我的程序中,我有一个名为 the_dictionary_list 的字典,描述如下:

the_dictionary_list = {'Color': ['Amarillo.png', 'Blanco.png', 'Rojirosado.png', 'Turquesa.png', 'Verde_oscuro.png', 'Zapote.png'], 'Cuerpo': ['Cuerpo_cangrejo.png'], 'Fondo': ['Oceano.png'], 'Ojos': ['Antenas.png', 'Pico.png', 'Verticales.png'], 'Pinzas': ['Pinzitas.png', 'Pinzotas.png', 'Pinzota_pinzita.png'], 'Puas': ['Arena.png', 'Marron.png', 'Purpura.png', 'Verde.png']}

现在,用户将被要求决定是否要将“None”项添加到字典中的数组中,然后他将被问到可用字典键中的哪一个将被更新为 None 文本,然后用户输入键的名称作为输入,输入可以在单引号内,也可以不在单引号内,只要它是有效的键,如果字典中不存在输入,他将不得不再次输入一个,直到他不想再更新可用的字典键之一:

entrada = input('All right, do you want to add a "None" item to an array in the dictionary? (y/n):')
while True:

if entrada == 'y':
    while True:
        key_entrada = input('Cool, now tell me at which key do you want me to add a "None" item? Type only a valid key name:')
        if key_entrada.startswith("'") & key_entrada.endswith("'"):
            if key_entrada in the_dictionary_list:
                the_dictionary_list[key_entrada].insert(0, 'None')
                entrada = input('Do you want to add another one? (y/n):')
                if entrada == 'n':
                    print('ta weno')
                    break
                if entrada == 'y':
                    break
                else:
                    break
            else:
                key_entrada = input('That input does not exist in the dictionary, try again, Type only a valid key name:')
                
        else:
            print('you did not put single quotation marks, let me add them to your input')
            comillas = str("'")+key_entrada+str("'")
            if comillas in the_dictionary_list:
                the_dictionary_list[comillas].insert(0, 'None')
                entrada = input('Do you want to add another one? (y/n):')
                if entrada == 'n':
                    print('ta weno')
                    break
                if entrada == 'y':
                    break
                else:
                    break                        
            else:
                key_entrada = input('That input does not exist in the dictionary, try again, Type only a valid key name:')
            
if entrada == 'n':
    print('weno')
    break

else:
    entrada = input("Invalid Input, Type 'y' or 'n' without single quotation marks: ")

它应该按预期工作,但是在测试之后我得到了以下输出:

All right, do you want to add a "None" item to an array in the dictionary? (y/n):y

Cool, now tell me at which key do you want me to add a "None" item? Type only a valid key name:Pinzas

you did not put single quotation marks, let me add them to your input

That input does not exist in the dictionary, try again, Type only a valid key name:'Pinzas'

Cool, now tell me at which key do you want me to add a "None" item? Type only a valid key name:'Pinzas'

That input does not exist in the dictionary, try again, Type only a valid key name:

我很确定我的编码是正确的,但也许我省略了一些重要的步骤或在这里做了一些“非法”的事情,所以我想听听你们的意见您认为是什么导致此程序无法按预期运行?

期望的最终输出应该是这样的:

the_dictionary_list:
{'Color': ['Amarillo.png', 'Blanco.png', 'Rojirosado.png', 'Turquesa.png', 'Verde_oscuro.png', 'Zapote.png'], 'Cuerpo': ['Cuerpo_cangrejo.png'], 'Fondo': ['Oceano.png'], 'Ojos': ['Antenas.png', 'Pico.png', 'Verticales.png'], 'Pinzas': ['None', 'Pinzitas.png', 'Pinzotas.png', 'Pinzota_pinzita.png'], 'Puas': ['None', 'Arena.png', 'Marron.png', 'Purpura.png', 'Verde.png']}

对于用户决定仅更新 PinzasPuas 键的情况。

问题解决了,多亏了@JohnGordon,他以某种方式照亮了我:

entrada = input('All right, do you want to add a "None" item to an array in the dictionary? (y/n):')

while True:

if entrada == 'y':
    key_entrada = input('Cool, now tell me at which key do you want me to add a "None" item? Type only a valid key name:')
    while True:            
        if key_entrada in the_dictionary_list:
            the_dictionary_list[key_entrada].insert(0, 'None')
            key_entrada = input('Do you want to add another one? (y/n):')
            if key_entrada == 'n':
                entrada = 'n'
                break
            if key_entrada == 'y':
                key_entrada = input('Cool, now tell me at which key do you want me to add a "None" item? Type only a valid key name:')
            else:
                key_entrada = input("Invalid Input, Type 'y' or 'n' without single quotation marks: ")
        else:
            key_entrada = input('That input does not exist in the dictionary, try again, Type only a valid key name:')               
                               
if entrada == 'n':
    print('weno')
    break  

elif entrada != 'y' or entrada != 'n':
    entrada = input("Invalid Input, Type 'y' or 'n' without single quotation marks: ")**strong text**