Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python get index of item in 2d list

myList = [[1, 2], [3, 4], [5, 6]]


def index_2d(myList, v):
    for i, x in enumerate(myList):
        if v in x:
            return i, x.index(v)


print(index_2d(myList, 3))
# you get
# (1, 0)
Comment

PREVIOUS NEXT
Code Example
Python :: how to replace zero with null in python 
Python :: replicate python 
Python :: how to keep old content when using write in python 
Python :: append in dictionary with matrix values 
Python :: python load array 
Python :: skit learn decision 
Python :: python ocr pdf dataframe 
Python :: find a string hackereank 
Python :: Print Odd Even Negative Integer Count 
Python :: Ordering column names sensibly in pandas 
Python :: appending hdf5 files 
Python :: converting 4hr 20min to minutes 
Python :: py3 dict values 
Python :: python consecutive numbers difference between 
Python :: python round and map function 
Python :: get all view port type dynamo revit 
Python :: legend matplotlib twinx 
Python :: fibonacci function python 
Python :: how to store svgs in django image field with SVGAndImageFormField 
Python :: python using string to access objects 
Python :: palindrome without using string function in python 
Python :: convert a column to camel case in python 
Python :: mechanize python #10 
Python :: struct trong Python 
Python :: reolace text python 
Python :: read(stdin, buf) ctf 
Python :: for _ in range python 
Python :: pairplot lower triangular 
Python :: changing speak rate pyttsx 
Python :: Command to install Voluptuous Python Library 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =