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

Ams BM
Ams BM
5,898 Points

My attempt Creating and Indexing Lists

This was a tough one and i did had to google a few time, but here's my code below for any feedback

players_name = []

add_player = input("Would you like to add a player to the list? (Yes/No): ")
while add_player.lower() == "yes":
  add_name = input("\nPlease enter the player name: ")
  players_name.append(add_name)
  add_player = input("Would you like to add 'another' player to the list? (Yes/No): ")

print(f"\nThere are {len(players_name)} players on your team")

for index, value in enumerate(players_name, 1):
  print(f"Player {index}: {value}")


goal_keeper = int(input(f"Please select the goal keeper, by selecting the players number. (1 - {len(players_name)}): "))

goal_keeper_pick = players_name[goal_keeper-1]

print(f"Great!!! The goalkeeper will be {goal_keeper_pick}")

1 Answer