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

Amr AbdelNasser
Amr AbdelNasser
1,745 Points

it seems like with this code if user answers "no" to first question they would still get asked to "select goal keeper"

how can i change the code to clear this out

1 Answer

Steven Parker
Steven Parker
231,275 Points

It would do as you say, but then it doesn't make sense to have no players on the team at all. A better solution might be to revise the code so that the question isn't asked until after the first player has been added:

print("Add the first player to the team.")    # these 2 lines replace the first "input"
add_players = 'yes'
while add_players.lower() == 'yes':           # (rest of code remains the same)
    # ...