How do we find a letter or special character present in list of strings? I have a list and want to check if it contains particular letter in it. I tried to do but getting an error.
code:
lst = ['Mangos*','apples,'REd']
for l in lst:
if l.contains('M') or l.contains('*'):
print(l)
getting an error:
AttributeError: 'list' object has no attribute 'contains'
Should we not use contains
? or what should we to find if a string has particular letter or special character?
lst = ['Mangos*','apples','REd']
for l in lst:
if 'M' in l or '*' in l:
print(l)