12345678910111213141516171819202122232425262728 |
- """
- Calculate percentage level of index for regions
- inside the Verenigde Nederlanden.
- """
- import re
- PLAYERS = {}
- def calculate_buildings():
- """Count number of buildings"""
- with open('military.txt', 'r') as file:
- for line in file:
- line = re.sub(r'\s\t\d\d.*', '', line)
- line = re.sub(r'\[.*\]', '', line)
- line = line.strip()
- if line in PLAYERS:
- PLAYERS[line] += 1
- else:
- PLAYERS[line] = 1
- for player in sorted(PLAYERS, key=PLAYERS.get, reverse=True):
- print('%2s %s' % (PLAYERS[player], player))
- if __name__ == '__main__':
- calculate_buildings()
|