select one of the words in the list [closed]

0

Type a word into a list and then search for the word you typed

lista = []
i = 0
palavra = ''
while (palavra.lower() != 'sair'):
    i += 1
    palavra = str(input('digite alguma palavra: '))
    lista.append(palavra)
ultima_palavra = len(lista) - 1
lista.remove(lista[ultima_palavra])
print(lista)
    
asked by anonymous 01.10.2018 / 15:24

1 answer

2

You have a useless variable i.

for palavra in lista:
    if palavra == buscada:
        print('a palavra buscada foi encontrada na lista')

Another way would be:

if buscada in lista:
    print('palavra encontrada')

I think you might have found the answer to your question on some other topic.

    
01.10.2018 / 15:57