Python code, Time delay on console text -


i'm making code should print text on console , every letter should came little delay. i've tried this

from time import sleep print "h", sleep(0.1), "e", sleep(0.1), "l", sleep(0.1), "l", sleep(0.1), "o" 

but puts random "none" there. should do? please :?:

sleep returns none, gets printed. print each char without newline , sleep:

import sys time import sleep  c in "hello":     print c,        # note comma     sleep(0.1) print               # final newline 

but avoid spaces inbetween, you'll have this:

import sys time import sleep  c in "hello":     sys.stdout.write(c)     sleep(0.1) sys.stdout.write('\n') 

depeding on environment, might need flush stdout buffer:

import sys time import sleep  c in "hello":     sys.stdout.write(c)     sys.stdout.flush()     sleep(0.1) sys.stdout.write('\n') sys.stdout.flush() 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -