Poonuts - 9 months ago 43
Python Question

# python compare string in list with item starting with \r\n

Ok so let's say i have a list.

l = ['a', '\r\nb']


And a known item to search for.

search = 'b'


If i type

search in l


It returns
False
. But if i type.

for item in l:
search in item


False
True


The latter one makes sense to me since
'b'
is in
'\r\nb'
. But why oh why isn't
'b'
in
['a', '\r\nb']

Because in the first case (search in l) it will try to find exact match for any element of the list with your search term .