Author: Not specified Language: text
Description: Not specified Timestamp: 2017-08-03 21:14:39 +0000
View raw paste Reply
  1. #!py
  2. string1 = 'A      B         C'
  3. string2 = 'D      E         F'
  4. string3 = '   G      H        I'
  5.  
  6. global_char1 = 'Undefined'
  7. global_space1 = 'Undefined'
  8. global_char2 = 'Undefined'
  9. global_space2 = 'Undefined'
  10. global_char3 = 'Undefined'
  11.  
  12. for string in string1, string2, string3:
  13.   column = 0
  14.   while True:
  15.     if string[column] != ' ':
  16.       char1 = column
  17.       print "First char found at " + str(column) + ' = ' + string[column]
  18.       if global_char1 == 'Undefined':
  19.         global_char1 = char1
  20.         print "Defined comparison_char1 as " + str(global_char1)
  21.       elif char1 != global_char1:
  22.           print "Columns don't match!!"
  23.           exit(2)
  24.       break
  25.     column += 1
  26.  
  27.   while True:
  28.     if string[column] == ' ':
  29.       space1 = column
  30.       print "First space found at " + str(column) + ' = ' + string[column]
  31.       if global_space1 == 'Undefined':
  32.         global_space1 = space1
  33.         print "Defined comparison_space1 as " + str(global_space1)
  34.       elif space1 != global_space1:
  35.           print "Columns don't match!!"
  36.           exit(2)
  37.       break
  38.     column += 1
  39.  
  40.   while True:
  41.     if string[column] != ' ':
  42.       char2 = column
  43.       print "Second char found at " + str(column) + ' = ' + string[column]
  44.       break
  45.     column += 1
  46.  
  47.   while True:
  48.     if string[column] == ' ':
  49.       space2 = column
  50.       print "Second space start found at " + str(column) + ' = ' + string[column]
  51.       break
  52.     column += 1
  53.  
  54.   while True:
  55.     if string[column] != ' ':
  56.       char3 = column
  57.       print "Third char found at " + str(column) + ' = ' + string[column]
  58.       break
  59.     column += 1
View raw paste Reply