# str_array.py - Program to draw table illustrating string contents and # corresponding index # This is not meant to be a simple program def main(): #Get string from user s = raw_input("Enter String: ") #Max number of digits an index value may need digits = len(str(len(s))) #Blank line for style print #String format with width of digits fmt = "%%%ii |" % digits #Print array values for pos in range(len(s)): print fmt % pos, #Bland line for next row print #String format with width of digits fmt = "%%%is |" % digits #Print contents at each index for char in s: print fmt % char, main()