
Mark Tripney
5,714 PointsSolution using enumerate...
A slightly different solution, using enumerate
to number the roster.
player_names = []
active = True
while active:
prompt = input("Would you like to add players to the list? ")
if prompt.lower() == "y":
prompt_name = input("OK. Please enter a name: ")
player_names.append(prompt_name)
else:
print("Roster:")
for number, player in enumerate(player_names, 1):
print("\t" + str(number), player.title())
print("There are", len(player_names), "players on the team.")
active = False
keeper = int(input("Who is the goalkeeper? "))
print(player_names[keeper - 1].title(), "is the keeper.")