Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. f = open('input.txt', encoding='utf-8')
  2. lines = f.readlines()
  3.  
  4. print(lines)
  5. counter = 0
  6. while lines[counter] != 'roles:\n':
  7.     counter = counter + 1
  8.  
  9. counter = counter + 1
  10. roles = {}
  11. while lines[counter] != 'textLines:\n':
  12.     roles[lines[counter].replace('\n', '')] = []
  13.     counter = counter + 1
  14.  
  15. counter = counter + 1
  16.  
  17. lineCounter = 1
  18. while (counter < len(lines)):
  19.     line = lines[counter]
  20.     roleInLine = line.split(':')[0]
  21.     for role, arr in roles.items():
  22.         if role.startswith(roleInLine):
  23.             arr.append("%d) %s" % (lineCounter, line[line.index(':') + 2:].rstrip('\n')))
  24.             lineCounter = lineCounter + 1
  25.     counter = counter + 1
  26.  
  27. for role, arr in roles.items():
  28.     print(role + ":")
  29.     for line in arr:
  30.         print(line)
  31.     print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement