You can use enumerate
inside a list-comprehension:
indices = [i for i, s in enumerate(mylist) if 'aa' in s]
More Related Contents:
- Python: How to check a string for substrings from a list? [duplicate]
- Delete substrings from a list of strings
- how to unpack a tuple in this form (‘abc’, [20, 20])? [closed]
- Getting the index of the returned max or min item using max()/min() on a list
- Why can tuples contain mutable items?
- Find and replace string values in list
- How to find most common elements of a list? [duplicate]
- How do you pick “x” number of unique numbers from a list in Python?
- How to convert list of key-value tuples into dictionary?
- Finding index of an item closest to the value in a list that’s not entirely sorted
- Find substring in string but only if whole words?
- Python split string into multiple string [duplicate]
- How to convert a list to a list of tuples?
- How to input matrix (2D list) in Python?
- Combining Dictionaries Of Lists In Python
- Check if list items contains substrings from another list
- accepting multiple user inputs separated by a space in python and append them to a list
- Python Bool and int comparison and indexing on list with boolean values
- Why do these list operations (methods: clear / extend / reverse / append / sort / remove) return None, rather than the resulting list?
- Comprehension on a nested iterables?
- Overriding append method after inheriting from a Python List
- Identify groups of consecutive numbers in a list
- List extending strange behaviour [duplicate]
- How to sort a 2D list? [closed]
- Mapping dictionary value to list
- Creating sublists [duplicate]
- How to sort a list of dictionaries by a value of the dictionary in Python?
- Why Python `Memory Error` with list `append()` lots of RAM left
- How to change variables fed into a for loop in list form
- list extend() to index, inserting list elements not only to the end