How to insert sleep into a list
<p>I am looking to create just a small module to implement the ability to text scroll. I've tried a few things so far and this is what I'm sitting on:</p>

<pre><code>from time import sleep

def text_scroll(x):
    x = x.split()
    #here is where I'd like to add the sleep function
    x = " ".join(x)

print x

text_scroll("hello world.")
</code></pre>

<p>With all this I am hoping to have it print "hello", sleep for a second, "world". The best I've gotten so far is it returning None instead of actually pausing.</p>

<p>Try the following code:</p>

<pre><code>from time import sleep
from sys import stdout

def text_scroll(text):
    words = text.split()
    for w in words:
        print w,
        stdout.flush()
        sleep(1)
</code></pre>

<p>The comma at the end of the print does not add new line '\n'.
The flush() function flushes the word into the screen (standard output).</p>

python sleep