military.py 673 B

12345678910111213141516171819202122232425262728
  1. """
  2. Calculate percentage level of index for regions
  3. inside the Verenigde Nederlanden.
  4. """
  5. import re
  6. PLAYERS = {}
  7. def calculate_buildings():
  8. """Count number of buildings"""
  9. with open('military.txt', 'r') as file:
  10. for line in file:
  11. line = re.sub(r'\s\t\d\d.*', '', line)
  12. line = re.sub(r'\[.*\]', '', line)
  13. line = line.strip()
  14. if line in PLAYERS:
  15. PLAYERS[line] += 1
  16. else:
  17. PLAYERS[line] = 1
  18. for player in sorted(PLAYERS, key=PLAYERS.get, reverse=True):
  19. print('%2s %s' % (PLAYERS[player], player))
  20. if __name__ == '__main__':
  21. calculate_buildings()