Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to find an item in an array in python

array = ['hello','people','i','want','icecream']
print(x.index('people'))
-> 1
Comment

search an array in python

# Python code to demonstrate
# searching an element in array
 
  
# importing array module
import array
  
# initializing array with array values
# initializes array with signed integers
arr = array.array('i', [1, 2, 3, 1, 2, 5])
 
# printing original array
print ("The new created array is : ", end ="")
for i in range (0, 6):
    print (arr[i], end =" ")
 
print ("
")
 
# using index() to print index of 1st occurrence of 2
print ("The index of 1st occurrence of 2 is : ", end ="")
print (arr.index(2))
 
# using index() to print index of 1st occurrence of 1
print ("The index of 1st occurrence of 1 is : ", end ="")
print (arr.index(1))
Comment

PREVIOUS NEXT
Code Example
Python :: why is python so popular 
Python :: numpy arange number of elements 
Python :: pine script to python 
Python :: how to print name in python 
Python :: quiz game in python 
Python :: vstack numpy 
Python :: python press any key to continue 
Python :: update python version pycharm 
Python :: how to check if user pressed enter in python 
Python :: append vector to vector python 
Python :: how to convert one dimensional array into two dimensional array 
Python :: how to learn regex pyton 
Python :: list append python 3 
Python :: How to code a simple rock, paper, scissors game on Python 
Python :: Convert .tif images files to .jpeg in python 
Python :: add column python list 
Python :: how to open chrome console in selenium webdriver 
Python :: python class declaration 
Python :: print statements 
Python :: selenium check if driver is open python 
Python :: reverse linked list python 
Python :: python subprocess no such file or directory 
Python :: # get the largest number in a list and print its indexes 
Python :: plague meaning 
Python :: remove percentage in python 
Python :: starry spheres 
Python :: multiclasshead 
Python :: Young C so new(pro.cashmoneyap x nazz music) soundcloud 
Python :: how many orders has customer made database python 
Shell :: Pyperclip could not find a copy/paste mechanism for your system 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =