Poonuts Poonuts - 1 year ago 95
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
. But if i type.

for item in l:
search in item

I will receive


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

Answer Source

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 .

And when you try to recursively go through each of the element and match it's finding in that element which it succseed to find.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download