Answers for "find item in list that contains string python"

2

python return first list element that contains substring

# Example usage:
your_list = ['The answer to', 'the ultimate question', 'of life', 
     'the universe', 'and everything', 'is 42']

[idx for idx, elem in enumerate(your_list) if 'universe' in elem][0]
--> 3 # The 0-based index of the first list element containing "universe"
Posted by: Guest on September-28-2020
8

check if anything in a list is in a string python

y = any(x in String for x in List)
Posted by: Guest on April-10-2020
1

python list contains string

str in strList

# example
if 'qwe' in strList:
	print('Yes!')
Posted by: Guest on August-19-2021
1

python find string in list

list1 = ["a", "b", "c"]

isBInList = "b" in list1 # True
Posted by: Guest on August-23-2020

Code answers related to "find item in list that contains string python"

Python Answers by Framework

Browse Popular Code Answers by Language