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
Johnathon Hollyfield
1,295 PointsI get an error when answering no to the first question? "would you like to add..." How do I adjust my else to work?
team_players = []
add 3 players to team
add_players = input ('Would you like to add a player to the list? Yes/No? ')
while len(team_players) <3: if add_players == 'Yes': player = input ('Enter the name of the player you wish to add: ') team_players.append(player) else: break print(team_players)
print number of players on roster
team_roster = team_players print (len(team_roster))
print players number and name
player_1 = team_roster[0] player_2 = team_roster[1] player_3 = team_roster[2]
print ('Player 1: ', player_1) print ('Player 2: ', player_2) print ('Player 3: ', player_3)
select a goalie
goalie = input (' Pleast select the goalkeeper by selecting player number. (1-3) ') if goalie == 1: go_sel = 'Great the goalkeeper for the game will be {}'.format(player_1) print(go_sel)
elif goalie == 2: go_sel_2 = 'Great the goalkeeper for the game will be {}'.format(player_2) print(go_sel_2)
else: go_sel_3 ='Great the goalkeeper for the game will be {}'.format(player_3) print(go_sel_3)
1 Answer
Steven Parker
243,134 PointsWhen posting code to the forum, use Markdown formatting to preserve the appearance, or share the entire workspace by making a snapshot and posting the link to it.
With code pasted in without formatting, indentation (which is critical in Python) cannot be seen.