Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open('input.txt', encoding='utf-8')
- lines = f.readlines()
- print(lines)
- counter = 0
- while lines[counter] != 'roles:\n':
- counter = counter + 1
- counter = counter + 1
- roles = {}
- while lines[counter] != 'textLines:\n':
- roles[lines[counter].replace('\n', '')] = []
- counter = counter + 1
- counter = counter + 1
- lineCounter = 1
- while (counter < len(lines)):
- line = lines[counter]
- roleInLine = line.split(':')[0]
- for role, arr in roles.items():
- if role.startswith(roleInLine):
- arr.append("%d) %s" % (lineCounter, line[line.index(':') + 2:].rstrip('\n')))
- lineCounter = lineCounter + 1
- counter = counter + 1
- for role, arr in roles.items():
- print(role + ":")
- for line in arr:
- print(line)
- print()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement