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 Challenge Solution

My code won`t run

Line 13 you are asking for user input so the keeper would need an 'input' like you did at the start ie. (keeper = input("Please choose a goalkeeper...")

Because of that, the input function in python stores a string, so when performing a maths calculation you will need to convert this to an integer first. So line 16 should be ' .format(players[int(keeper) - 1])) '. Notice the int wrapping the keeper variable.

This will now run, but I'd recommend considering how to deal with incorrect inputs for example if the user enters a string instead of number in line 13.

1 Answer

Steven Parker
Steven Parker
231,275 Points

It looks like you are just missing the line shown in the video on line 30 that would convert the input into a number:

keeper = int(keeper)

In your version, it would go on line 14 or 15.