Python Challenge Solution

Falah Sadiq
Falah Sadiq
1,383 Points

My code won`t run

Ryan Smith
Ryan Smith
2,908 Points

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
195,592 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.