Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: The Champions League | Mastering Packing and Unpacking in Python
Intermediate Python Techniques

book
Challenge: The Champions League

Task

Swipe to start coding

Imagine we have a table with the final results of the qualification round for the Champions League. Let's store the teams with first and second place in the team_a and team_b. The third team save in the team_c variable. Save the team with the fewest points in the last team_d variable. We will use these variables to print the announcements.

Please don't change the print statements and the function.

Your task is simply to unpack the list group_c within the function call parameters.

Solution

def announcements(team_a, team_b, team_c, team_d):
print(f"The teams that move to the next round are {team_a} and {team_b}.")
print(f"The team that will play in the Europa League group stage is {team_c}.")
print(f"{team_d} is out of the Champions League.")


group_c = ["Bayern", "Inter", "Barcelona", "Viktoria Plzen"]
announcements(*group_c)

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 5
def announcements(team_a, team_b, team_c, team_d):
print(f"The teams that move to the next round are {team_a} and {team_b}.\n"
f"The team that will play in the Europa League group stage is {team_c}.\n"
f"{team_d} is out of the Champions League.")


group_c = ["Bayern", "Inter", "Barcelona", "Viktoria Plzen"]
announcements(___)

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt