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

could goalkeeper selecting be simpler?

seems like this:

goalkeeper = input("Please select a goalkeeper from the list and enter the player number:  ")
goalkeeper = int(goalkeeper) -1

print("Goalkeeper: {}".format(player_names[goalkeeper]))

would be simpler than this:

keeper = input("Please select the goal keeper by selecting the player number. (1-{})".format(len(players)))
keeper = int(keeper)

print("Great!!! The goalkeeper for the game will be {}".format(players[keeper - 1]))

I also don't understand (1-{})".format(len(players))...why would he do this?

2 Answers

Hey tyler borg, I'm not really sure if you need that -1 or any of that... but hey nice try! this the simplest way you could probably go for.

goalkeeper = input("Please enter the Goalkeeper's number from the list:\n ") goalkeeper = int(goalkeeper)

print("Your Goalkeeper for this match will be player number: {}".format(goalkeeper))

replay to me if you meant something else or if you wanted in some other way....I'll try my best to help you my guy. goodluck and happy coding...!

thanks for your reply, jassim Al-Hatem ...It seems like your answer is similar to mine, except I believe that you do need the -1 because the list indexing starts at [0], whereas the player list that we made starts at 1.