Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filename = input()
- f = open(filename, 'r')
- data = f.readlines()
- f.close()
- dictionary = {}
- list_of_values =[]
- for i in range(len(data)):
- data[i] = data[i].strip()
- for i in range(0, len(data), 2):
- list_of_values.append(data[i+1])
- if data[i] in dictionary:
- dictionary[data[i]] = "{}; {}".format((dictionary[data[i]]),data[i+1])
- else:
- dictionary[data[i]] = data[i+1]
- f = open('output_keys.txt', 'w')
- for item in sorted(dictionary.items()):
- f.write(str(item[0])+': '+item[1]+'\n')
- f.close()
- f = open('output_titles.txt', 'w')
- list_of_values.sort()
- for each in list_of_values:
- f.write(each+'\n')
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement