I'm trying to get a list like this, where the two collected numbers are sum together and deliver the final result of that sum team1Goals + team2Goals:
FT 4 + 1 - Atletico El Vigia v Llaneros de Guanare
Postp. 1 + 2 - Deportivo Lara B v Atletico El Vigia
Postp. 0 + 0 - Llaneros de Guanare v Urena SC
FT 1 + 0 - Rayo Zuliano v Universidad de Los Andes FC
Expected Result:
FT 5 - Atletico El Vigia v Llaneros de Guanare
Postp. 3 - Deportivo Lara B v Atletico El Vigia
Postp. 0 - Llaneros de Guanare v Urena SC
FT 1 - Rayo Zuliano v Universidad de Los Andes FC
I tried using the sum() method, but it gives me an error and even giving me a hint that I honestly don't know how to go about using:
TypeError: sum() can't sum strings [use ''.join(seq) instead]
response = requests.get(url, headers=headers).json()
stages = response['Stages']
for stage in stages:
events = stage['Events']
for event in events:
outcome = event['Eps']
team1Name = event['T1'][0]['Nm']
if 'Tr1OR' in event.keys():
team1Goals = event['Tr1OR']
else:
team1Goals = '0'
team2Name = event['T2'][0]['Nm']
if 'Tr2OR' in event.keys():
team2Goals = event['Tr2OR']
else:
team2Goals = '0'
print('%s\t%s - %s v %s' %(outcome, [sum(team1Goals,team2Goals)], team1Name, team2Name))
What you are getting?andWhat you want?