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

book
Challenge: The Champions League

Opgave

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.

Løsning

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)

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 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(___)

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt