Search an array for a string to get its index in python

Poulami Paul

I want to search an array for a string and get its index number.

li = ["New Year's Day", 'Lohri', 'Pongal', 'Makar Sankranti', 'Guru Govind Singh Jayanti', 'Republic Day', 'Chinese New Year', "Valentine's Day", 'Vasant Panchami', 'Shivaji Jayanti']

So what should I write to make it return the index number
like I call a faction check = checkindex('Pongal') and this should return 2. How do I write this function.

AJITH

You don't need a separate function for that

li.index('Pongal')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how can print big string from a string array or get its index

Swift: Search for String inside String and get Index

Get max value and its index in numpy array

get json elements with array index in its name

Get the list of index for a string in an array?

How to get the index of a string in an array?

how to search for the value with a certain index in an array and modify its value?

This is a program to search a number and also display its index position if found in an array

Get Index of the search array with .all() and any()

search contains string in array python

Is 'search' causing 'String index out of range' ? (Python)

how can I get the index of the item in a list that contains the string being search (within the list) in python

How to Search a CSV file for a String and get It's Row Index In Python 2.7

Search in Array and get specific string value

How to check if an item exists in a string List and if it exists, get its index

How to get the element from a delimited string by its index?

Java - How to get item index from an array with its value?

recognize which UIImageView has been tapped and get its index in an array

Is there a way to get the index of an array struct in its function without parameters?

How to get element of array with string index path

How to get the index of numpy string array?

Python - Check if part of a string exists in a list and give the index of its match

Put a character by according to a list of its index number to a string [Python 2.7]

Slicing Data Frame through its Index and array in python

How to get frame from video by its index via OpenCV and Python?

Get the index of xml element according to its attribute / Python

c#: search in string array and get specific string value

Search a sorted integer array for an element equal to its index, where A may have duplicate entries

Search String array for String