Lists have an index method that you can use

def checkLen(): 
     days = ["Monday", "Tuesday", "Wednesday", "Thursday" "Friday", "Saturday", "Sunday"]
     try:
         position = days.index("Monday")
         print("Found it") 
     except ValueError:
         position = None # or 0 if you want
         print("Not present") 
     print(position)
Answer from lurknobserve on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-find-index-containing-string-in-list
Python - Find Index containing String in List - GeeksforGeeks
July 23, 2025 - It involves identifying the position where a specific string appears within the list. index() method in Python is used to find the position of a specific string in a list.
🌐
Built In
builtin.com › software-engineering-perspectives › python-substring-indexof
5 Ways to Find the Index of a Substring in Python | Built In
The index() method in Python finds the first occurrence of a specific character or element in a string or list. If the character or element is found, its index value will be returned.
Top answer
1 of 16
6115
>>> ["foo", "bar", "baz"].index("bar")
1

See the documentation for the built-in .index() method of the list:

list.index(x[, start[, end]])

Return zero-based index in the list of the first item whose value is equal to x. Raises a ValueError if there is no such item.

The optional arguments start and end are interpreted as in the slice notation and are used to limit the search to a particular subsequence of the list. The returned index is computed relative to the beginning of the full sequence rather than the start argument.

Caveats

Linear time-complexity in list length

An index call checks every element of the list in order, until it finds a match. If the list is long, and if there is no guarantee that the value will be near the beginning, this can slow down the code.

This problem can only be completely avoided by using a different data structure. However, if the element is known to be within a certain part of the list, the start and end parameters can be used to narrow the search.

For example:

>>> import timeit
>>> timeit.timeit('l.index(999_999)', setup='l = list(range(0, 1_000_000))', number=1000)
9.356267921015387
>>> timeit.timeit('l.index(999_999, 999_990, 1_000_000)', setup='l = list(range(0, 1_000_000))', number=1000)
0.0004404920036904514

The second call is orders of magnitude faster, because it only has to search through 10 elements, rather than all 1 million.

Only the index of the first match is returned

A call to index searches through the list in order until it finds a match, and stops there. If there could be more than one occurrence of the value, and all indices are needed, index cannot solve the problem:

>>> [1, 1].index(1) # the `1` index is not found.
0

Instead, use a list comprehension or generator expression to do the search, with enumerate to get indices:

>>> # A list comprehension gives a list of indices directly:
>>> [i for i, e in enumerate([1, 2, 1]) if e == 1]
[0, 2]
>>> # A generator comprehension gives us an iterable object...
>>> g = (i for i, e in enumerate([1, 2, 1]) if e == 1)
>>> # which can be used in a `for` loop, or manually iterated with `next`:
>>> next(g)
0
>>> next(g)
2

The list comprehension and generator expression techniques still work if there is only one match, and are more generalizable.

Raises an exception if there is no match

As noted in the documentation above, using .index will raise an exception if the searched-for value is not in the list:

>>> [1, 1].index(2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: 2 is not in list

If this is a concern, either explicitly check first using item in my_list, or handle the exception with try/except as appropriate.

The explicit check is simple and readable, but it must iterate the list a second time. See What is the EAFP principle in Python? for more guidance on this choice.

2 of 16
725

The majority of answers explain how to find a single index, but their methods do not return multiple indexes if the item is in the list multiple times. Use enumerate():

for i, j in enumerate(['foo', 'bar', 'baz']):
    if j == 'bar':
        print(i)

The index() function only returns the first occurrence, while enumerate() returns all occurrences.

As a list comprehension:

[i for i, j in enumerate(['foo', 'bar', 'baz']) if j == 'bar']

Here's also another small solution with itertools.count() (which is pretty much the same approach as enumerate):

from itertools import izip as zip, count # izip for maximum efficiency
[i for i, j in zip(count(), ['foo', 'bar', 'baz']) if j == 'bar']

This is more efficient for larger lists than using enumerate():

$ python -m timeit -s "from itertools import izip as zip, count" "[i for i, j in zip(count(), ['foo', 'bar', 'baz']*500) if j == 'bar']"
10000 loops, best of 3: 174 usec per loop
$ python -m timeit "[i for i, j in enumerate(['foo', 'bar', 'baz']*500) if j == 'bar']"
10000 loops, best of 3: 196 usec per loop
🌐
Programiz
programiz.com › python-programming › methods › list › index
Python List index()
The index() method returns the index of the given element in the list.
🌐
FavTutor
favtutor.com › blogs › get-list-index-python
Python Find String Position in List (Get the Index of an Item)
1 week ago - Learn how to find the position of a string in a list in Python using index(), enumerate, and in, with examples for all positions and safe searching.
🌐
W3Schools
w3schools.com › python › ref_string_index.asp
Python String index() Method
Python Strings Slicing Strings Modify Strings Concatenate Strings Format Strings Escape Characters String Methods String Exercises Code Challenge Python Booleans ... Python Operators Arithmetic Operators Assignment Operators Ternary Operator Comparison Operators Logical Operators Identity Operators Membership Operators Bitwise Operators Operator Precedence Code Challenge Python Lists
🌐
TechBeamers
techbeamers.com › python-string-indexof
How to Use String indexOf in Python - TechBeamers
November 30, 2025 - The indexOf method helps locate a substring in a string, pointing to its first appearance. In Python, there isn’t a direct string indexOf method. But we can achieve the same functionality using…
Find elsewhere
🌐
Skill Matrix Academy
skillsmatrixacademy.com › home › python list index() method explained with practical examples
Python list index() Method Explained with Practical Examples
November 7, 2025 - The output will be “H”. Here, you accessed the first string element index using the square bracket notation. In short, Python indexing lets you grab data directly without looping through the entire structure. The Python index() Function saves you from writing manual loops to find positions. It’s faster, cleaner, and perfect for large datasets or complex structures. If the value you’re looking for isn’t in the list, a ValueError in Python is raised.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-index-method
Python String index() Method - GeeksforGeeks
May 2, 2025 - Explanation: index() method searches for the substring "prog" within "Python programming" and returns starting index 7. ... end (optional): The ending index for the search. If not provided, it defaults to the length of the string.
🌐
Quora
quora.com › How-do-I-find-the-index-of-a-character-in-a-string-in-Python
How to find the index of a character in a string in Python - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
GeeksforGeeks
geeksforgeeks.org › python › find-the-index-of-a-substring-in-python
Find the Index of a Substring in Python - GeeksforGeeks
July 23, 2025 - In this article, we will explore some simple and commonly used methods to find the index of a substring in Python. The find() method searches for the first occurrence of the specified substring and returns its starting index.
🌐
datagy
datagy.io › home › python posts › python strings › python: find an index (or all) of a substring in a string
Python: Find an Index (or all) of a Substring in a String • datagy
December 20, 2022 - We imported re and set up our variable a_string just as before · We then use re.finditer to create an iterable object containing all the matches · We then created a list comprehension to find the .start() value, meaning the starting index position of each match, within that · Finally, we printed our list of index start positions · In the next section, you’ll learn how to use a list comprehension in Python to find all indices of a substring in a string.
🌐
Simplilearn
simplilearn.com › home › resources › software development › python index: mastering list indexing techniques
Python List index() Method Explained with Examples
3 weeks ago - The Python index() method helps you find the index position of an element or an item in a string of characters or a list of items.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
W3Schools
w3schools.com › python › ref_list_index.asp
Python List index() Method
Python Strings Slicing Strings Modify Strings Concatenate Strings Format Strings Escape Characters String Methods String Exercises Code Challenge Python Booleans ... Python Operators Arithmetic Operators Assignment Operators Ternary Operator Comparison Operators Logical Operators Identity Operators Membership Operators Bitwise Operators Operator Precedence Code Challenge Python Lists
🌐
Tutorial Teacher
tutorialsteacher.com › python › string-index
Python string.index() Method (With Examples)
The index() method returns the index of the first occurence of a substring in the given string. It is same as the find() method except that if a substring is not found, then it raises an exception.
🌐
TutorialsPoint
tutorialspoint.com › article › python-find-index-containing-string-in-list
Python - Find Index Containing String in List
March 27, 2026 - When searching for all indices of a particular string value, use this approach ? def find_all_indices(target, search_list): indices = [] start = 0 while True: try: index = search_list.index(target, start) indices.append(index) start = index + 1 except ValueError: break return indices test_list = ["Python", "Java", "Python", "C++", "Python"] result = find_all_indices("Python", test_list) print(f"All indices of 'Python': {result}")
🌐
Medium
medium.com › @muraliairody › find-and-index-of-string-6c50c819273c
Find and Index of String
October 24, 2025 - Optional start and end parameters let you search within a slice of the string. ... text = "Hello Python" print(text.find("Python")) # 6 print(text.find("Java")) # -1 print(text.find("o")) # 4 (first occurrence)
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-index-and-slice-strings-in-python-3
How To Index and Slice Strings in Python | DigitalOcean
September 29, 2025 - For the string Sammy Shark! the index breakdown is like this: Character: S | a | m | m | y | | S | h | a | r | k | ! Positive: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 Negative: -12 | -11| -10| -9 | -8 | -7| -6 | -5 | -4 | -3 | -2 | -1 ... The fact that each character in a Python string ...