coding utf-8 __author__ pilgrim team_looking_for Arsenal open Foot txt

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
__author__ = 'pilgrim'
team_looking_for = 'Arsenal'
f = open('Foot.1.txt', 'r')
content = f.readlines()
content.reverse()
#Собираю все команды в 1 массив
list_of_teams = list()
for string in content:
for team in string.split(' '):
if team.isalpha() and team not in list_of_teams:
list_of_teams.append(team)
#считаю Х для всех команд для последней игры
for team_looking_for in list_of_teams:
num_of_entries = 0
last_team_delta = list()
for current_string in content:
if team_looking_for in current_string:
num_of_entries += 1
if num_of_entries == 1:
pass
word_number = 0
score_1 = 0
score_2 = 0
for element in current_string.split(' '):
word_number += 1
if word_number == 3: # кол-во голов хозяина
score_1 = int(element)
if word_number == 4: # кол-во голов гостей
score_2 = int(element)
if current_string.startswith(team_looking_for):
delta = score_1 - score_2
else:
delta = score_2 - score_1
last_team_delta.append(delta)
if num_of_entries == 6:
break
summa_delt = 0
for score in last_team_delta:
summa_delt += score
print team_looking_for, summa_delt # печатаю пару [КОМАНДА --- Х_для_последней_игры]
# читаю последнюю игру
count = 0
for current_str in content:
count += 1
if count < len(list_of_teams)/2:
print current_str
else:
break