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
Post a Comment