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 trialChaquayla Halmon
1,797 PointsThe freakin goalkeeper...
Okay so far so good with this challenge. I don't know if my brain just stop working or I'm overlooking a lesson. Here's my code:
So if there's a lesson that shows how to get an index from the input method please direct me there. I know how the get something from a list in the shell but I don't know how to get it from the code. I think...
Again my brain is fried...
2 Answers
ygh5254e69hy5h545uj56592yh5j94595682hy95
7,934 Points# above you have a list of all players stored in the variable roster
# you can use the roster len to fill in the (1-X) number
# also make sure you use int(input()) in order to get a integer input so that we can then access the roster with that integer
goal_keeper = int(input("Please select a goal keeper by the player's number. (1-{}): ".format(len(roster))))
# here we just use the index number to get the goal keeper's name.
# we use [goal_keeper - 1] because an array starts with 0, 1, 2, 3, 4...etc
# so we have match the way a list is structured
print("Your goalkeeper is {}".format(roster[goal_keeper-1]))
# hopefully this makes sense
Chaquayla Halmon
1,797 PointsThank you. That seems to work.