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 :: pygame change color mouse hover 
Python :: how to find if a value is even or odd in python 
Python :: how to plot a graph using matplotlib 
Python :: knowing the sum of null value is pandas dataframe 
Python :: turn pandas entries into strings 
Python :: python sort list of strings numerically 
Python :: remove negative numbers from list python 
Python :: discord.py send image 
Python :: get python version in code 
Python :: how to create chess board numpy 
Python :: center buttons tkinter 
Python :: drop columns pandas 
Python :: pytho list items to int 
Python :: convert list of int to string python 
Python :: how to remove first row of numpy array 
Python :: kivymd simple button 
Python :: mouse in pygame 
Python :: python display object attributes 
Python :: get video length python 
Python :: Extract categorical data features 
Python :: built in functions python 
Python :: how to manually click button godot 
Python :: virtualenv with specific python version 
Python :: get all classes from css file using python 
Python :: rename the console python 
Python :: pygame font 
Python :: Sin , Cos Graph using python turtle. 
Python :: open csv from google drive using python 
Python :: python decimal number into 8 bit binary 
Python :: 1 day ago python datetime 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =