reverse-lookup

Using Python's list index() method on a list of tuples or objects?

Using Python's list index() method on a list of tuples or objects? Question: Python’s list type has an index() method that takes one parameter and returns the index of the first item in the list matching the parameter. For instance: >>> some_list = [“apple”, “pear”, “banana”, “grape”] >>> some_list.index(“pear”) 1 >>> some_list.index(“grape”) 3 Is there …

Total answers: 13