Automatically put words in a list

Asked

Viewed 32 times

-2

I’m doing a program similar to a dictionary. When making a list to store words have some form of words, automatically get in quotes and have commas? For example, if I take multiple words from a website using crtl C it’s like I give crtl V and the words become a list automatically, or I have to put ' ' and , manually?

1 answer

0


If the words are separated by space you can do so:

lista = []
entrada = input()
palavras = entrada.split(' ')
for palavra in palavras:
    lista.append(palavra)
print(lista)

Entree:
Estou fazendo um programa similar a um dicionário

Exit:
['Estou', 'fazendo', 'um', 'programa', 'similar', 'a', 'um', 'dicionário']

Browser other questions tagged

You are not signed in. Login or sign up in order to post.