Python Challenge Solution

Jamar Slade
Jamar Slade
2,472 Points

Variable assignment issue. Giving me a SyntaxError

Need a little help figuring out where my code has gone wrong. It seems it keeps telling me I have a syntax error, but I cannot figure out what it's trying to tell me. I've deleted the line, moved it and made sure there was no indent issues and just can't seem to figure it out.

TODO Create an empty list to maintain the player names

roster = []

TODO Ask the user if they'd like to add players to the list.

added_players = input('Would you like to add more players to the list? ') while added_players.lower() == yes: name = input("\n Players Name? ") roster.append('name') added_players = input('Would you like to add more players to the list? ')

print("/n There are {} players on the team.".format(len([roster]))

TODO Print the player number and the player name

player_number = 1 (THIS LINE HERE THEY'RE SAYING IS THE PROBLEM) for player in roster: print('Player {}: {}'.format(player_number, name)) player_number += 1

TODO Select a goalkeeper from the above roster

Goalie = input("Who's the Goalkeeper? ") print("{} is the goal keeper".format(Goalie)

TODO Print the goal keeper's name

Remember that lists use a zero based index

1 Answer

Many times for a syntax error you should look at the line above the one indicated. In this case you will see:

print("/n There are {} players on the team.".format(len([roster]))

is missing a closing parenthesis for print().

You have the same thing going on here as well:

print("{} is the goal keeper".format(Goalie)

There are a few more errors but that will get you started

Jamar Slade
Jamar Slade
2,472 Points

Thanks Kris, I never knew that. Appreciate your help.