Can somebody explain to me the following (python 2.7)
Two string numbers, from a parsed file:
'410.9' '410.9 ' (Notice the trailing space)
A_LIST = ['410.9 ']
'410.9' in '410.9 '
True
'410.9' in A_LIST
False
No problem working around this - just trying to understand why it is so.
Thanks!
in
with two strings checks or a substring, whereas in
with a list checks for membership.
What you want is something like [x for x in A_LIST if '419' in x]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With