To reference a value of a list in a user input request in python, you need to first get the index of the value in the list, then use that index to reference the value in the user input. Here's an example:
main.py264 chars9 lines
In this example, the user is prompted to enter the index of the animal they want to reference. The index is then converted to an integer using the int()
function. Finally, the index is used to reference the value in the list and print it to the console. Keep in mind that the index starts at 0, so the first item in the list has an index of 0, the second item has an index of 1, and so on.
gistlibby LogSnag