我有两个关于使用嵌套循环的问题。
colors = []
for color in soccer_match:
colors.append(color['colors'])
colors
Run Code Online (Sandbox Code Playgroud)
这给了我[['蓝色','白色','红色'],['绿色','金色']]。我怎样才能将两个列表合并为一个?我还没有学习列表理解或函数。
这是给定的示例。谢谢你!
soccer_match = [
{ "home_team": True,
"away_team": False,
"country": "France",
"num_passes": 484,
"passes_completed": 423,
"fouls_committed": 16,
"colors": ["blue", "white", "red"],
"players": [
{
"name": "Hugo LLORIS",
"captain": True,
"shirt_number": 1,
"position": "Goalie"
},
{
"name": "Benjamin PAVARD",
"captain": False,
"shirt_number": 2,
"position": "Defender"
},
{
"name": "Raphael VARANE",
"captain": False,
"shirt_number": 4,
"position": "Defender"
},
{
"name": …Run Code Online (Sandbox Code Playgroud)