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.

14th Mar 2019, 6:22 PM
Jordi
Jordi - avatar
2 Answers
+ 4
You can see one possible solution https://code.sololearn.com/cJ9e0O7dRsZT/?ref=app
14th Mar 2019, 6:31 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 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)
14th Mar 2019, 6:28 PM
Russ
Russ - avatar