I am trying to combine multiple lists in selected format. Simply, trying to create
elapsed + "' " + player + ' (A: ' + assist + ') - ' + detail (for example: 51' H. Onyekuru (A: R. Babel) - Normal Goal ). I also added the json file i took the data. Maybe it can be created directly without creating lists.
Code:
elapsed = []
player = []
assist = []
detail = []
for item in data['response']:
player.append(item['player']['name'])
for item in data['response']:
elapsed.append(item['time']['elapsed'])
for item in data['response']:
assist.append(item['assist']['name'])
for item in data['response']:
detail.append(item['detail'])
JSON file:
{
"get": "fixtures/events",
"parameters": { "fixture": "599120", "type": "goal" },
"errors": [],
"results": 3,
"paging": { "current": 1, "total": 1 },
"response": [
{
"time": { "elapsed": 51, "extra": null },
"team": {
"id": 645,
"name": "Galatasaray",
"logo": "https://media.api-sports.io/football/teams/645.png"
},
"player": { "id": 456, "name": "H. Onyekuru" },
"assist": { "id": 19034, "name": "R. Babel" },
"type": "Goal",
"detail": "Normal Goal",
"comments": null
},
{
"time": { "elapsed": 79, "extra": null },
"team": {
"id": 645,
"name": "Galatasaray",
"logo": "https://media.api-sports.io/football/teams/645.png"
},
"player": { "id": 456, "name": "H. Onyekuru" },
"assist": { "id": 142959, "name": "K. Akturkoglu" },
"type": "Goal",
"detail": "Normal Goal",
"comments": null
},
{
"time": { "elapsed": 90, "extra": 7 },
"team": {
"id": 3573,
"name": "Gazi\u015fehir Gaziantep",
"logo": "https://media.api-sports.io/football/teams/3573.png"
},
"player": { "id": 25921, "name": "A. Maxim" },
"assist": { "id": null, "name": null },
"type": "Goal",
"detail": "Penalty",
"comments": null
}
]
}
Output:
['H. Onyekuru', 'H. Onyekuru', 'A. Maxim']
[51, 79, 90]
['R. Babel', 'K. Akturkoglu', None]
['Normal Goal', 'Normal Goal', 'Penalty']
.appendstatements into the same loop and it will give you the same output.