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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -