Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Challenge Solution

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

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