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
Jesse Busby
966 PointsI'm having a syntax error that I don't know how to fix.
this text says It has invalid syntax around the 'while' word.
while add_players.lower() == 'Y':
Am I doing something wrong?
1 Answer
Steven Parker
243,344 PointsCheck to be sure that "add_players" is a string variable. That name sounds more like something you might call a function, and a function would not have a ".lower()" method.
And Kris makes a good point. Anything converted to lower case could never match a capital "Y".
Jesse Busby
966 PointsTODO Create an empty list to maintain the player names
soccer_list = []
TODO Ask the user if they'd like to add players to the list.
If the user answers "Yes", let them type in a name and add it to the list.
If the user answers "No", print out the team 'roster'
add_players = input("Do you want to sign up a soccer team? [Y/N] "
while add_players.lower() == 'y': name = input("What is the Player's name? ") soccer_list.append(name) add_players = input("Do you want to add another player? [Y/N] "
TODO print the number of players on the team
TODO Print the player number and the player name
The player number should start at the number one
TODO Select a goalkeeper from the above roster
TODO Print the goal keeper's name
Remember that lists use a zero based index
here's the rest of it, while fixing that lower y (thanks for that btw)
Steven Parker
243,344 PointsTo make your code look right, you need to use "Markdown" formatting. There is a video on code formatting you might want to watch.
But even as it is, I notice that there is a missing close parenthesis at the end of the "input" call on the line just before the "while". I'll bet that's the cause of the syntax error.
KRIS NIKOLAISEN
54,974 PointsKRIS NIKOLAISEN
54,974 PointsCan you post all of your code? Also shouldn't the Y be lowercase since you are testing lower()?