I'm trying to separate a long string into different words that I will print off with a .1 second delay on the same line.
Asked
Active
Viewed 95 times
-1
-
look into [str.split](https://python-reference.readthedocs.io/en/latest/docs/str/split.html) – DSC Jun 22 '19 at 16:28
-
1Welcome to StackOverflow. Please go through the "How to ask a good question" [link](https://stackoverflow.com/help/how-to-ask) in SO Help Center. Please describe what you have tried so far, what is not working, and what is the desired output. – UdonN00dle Jun 22 '19 at 16:29
-
1String `split` and `time` module help you with this. What have you tried so far? – Austin Jun 22 '19 at 16:29
1 Answers
0
You can split according to the space between them:
from time import sleep
string = "hello world"
words = string.split(' ') # splits the string into parts divided by ' '
for w in words:
print(w, end=' ')
sleep(0.1) #delays for 0.1 seconds

Vikhyat Agarwal
- 1,723
- 1
- 11
- 29
-
In order to keep it all on the same line you will need to apply a `,` after the print statement. i.e. `print(w),` – TheLazyScripter Jun 22 '19 at 16:36