0
save input into an array
words = [] TranslatedText = str(input("Enter the text you want to translate: ")) #fe Hello World words.append(TranslatedText) print(words) when i do this, it works but the output is ['Hello World']. How can i make it so the output is ['Hello', 'World'] I want it to be like that so i can access each word...idk how to do it if it's 1 string.
2 Answers
+ 4
You can see one possible solution
https://code.sololearn.com/cJ9e0O7dRsZT/?ref=app
+ 2
Use split() method.
âHello Worldâ.split() -> [âHelloâ, âWorldâ]
In your example, simply do
words = input("Enter the text you want to translate: ").split()
print(words)