Slug
Slug

Reputation: 1

How to change python list returns from letters to numbers

How can I return where something is located on a list? For example, if you have List = [a, b, c] and the user inputs c the program should return 2. How can I code this though?

Upvotes: 0

Views: 27

Answers (1)

sebastian_oe
sebastian_oe

Reputation: 7340

Try this:

> my_list = ["a", "b", "c"]

> my_list.index("c")
2

Upvotes: 1

Related Questions