Assuming I want to use the position of an element in a 2d list knowing the element itself, what would be the command to find the index?
For a simple list the method list.index(element)
works, for example:
my_list = ["banana", "yam", "mango", "apple"]
print(my_list.index("yam")
>> 1
print(my_list[my_list.index("yam")])
>> yam
But the same method doesn't work for 2d arrays. For example:
array = [["banana", "yam"],["mango", "apple"]]
print(array.index("yam"))
I get a ValueError: 'yam' is not in list.