Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- people = {}
- with open('input1.txt') as f:
- for line in f:
- line = line.split(' ')
- client = line[0]
- product = line[1]
- num = int(line[2])
- if(client not in people):
- people[client] = {}
- if(product not in people[client]):
- people[client][product] = num
- else:
- people[client][product] += num
- list_keys = list(people.keys())
- list_keys.sort()
- for i in list_keys:
- print(i + ":")
- list_ = list(people[i].keys())
- list_.sort()
- for j in list_:
- print(j, people[i][j])
Add Comment
Please, Sign In to add comment