Printing Individual Characters of Strings Python -


my code reads

import time = raw_input("enter string: ") b = len(a) #print 1st letter of string time.sleep(2) #print 2nd letter of string #continue doing until last character in string 

what need make code in python 2.7? prods in right direction appreciated.

thank you.

you can iterate on string itself:

import time = raw_input("enter string: ") char in a:      #iterate on string 1 character @ time    print char    time.sleep(2)    # sleep after printing each character 

example:

>>> x in "foobar": ...     print x ...      f o o b r 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -