Reputation: 83
There is list in which the string line, how to search for the presence of value in the list? example value 'print'
tlist = ['Hello world',
'Hello world print',
'Text',
'World hello print']
Upvotes: 0
Views: 42
Reputation: 67968
tlist = ['Hello world',
'Hello world print',
'Text',
'World hello print']
print [i for i in tlist if "print" in i]
Upvotes: 2
Reputation: 8386
for i in tlist:
if 'print' in i:
print '"print" is in the line"'
Upvotes: 0