0

I want to use an input method to select an item from a list. I am a beginner and I am just trying to use my logic.

name_list = ["apple", "banana", "orange"]
choice = input("Enter your name here: ")
print(name_list[choice] -1)

It gives me an error: "list indices must be integers or slices, not str"

What is wrong with my code?

I expect the console to print out an item. For example if a user inputs 1 the console should print out: "apple"

alex
  • 3
  • 3

0 Answers0