Answers for "How to check if a list contains a "specific string" "python""

2

python list contains substring

str_list = ["one", "two", "three"]
substr = "wo"
if any(substr in str for str in str_list):
	print('Yes!')
Posted by: Guest on September-01-2021
15

python check if list contains

# To check if a certain element is contained in a list use 'in'
bikes = ['trek', 'redline', 'giant']
'trek' in bikes
# Output:
# True
Posted by: Guest on February-19-2020

Code answers related to "How to check if a list contains a "specific string" "python""

Python Answers by Framework

Browse Popular Code Answers by Language