Anurag Joshi Anurag Joshi - 5 months ago 41
Python Question

Compare non identical objects with same value

I have 2 lists,both in different formats but same content.
For example, doing a simple print command for the 1st elements of the list does the following:


I get the 'u' here is due to the encoding..

The prefix_confluence is being parsed by a HTML parser this way:

for row in soup.find_all('tr')[2:171]:
prefix_confluence.append(row.get_text(strip=True, separator='|').split('|')[0:1])

Now, how do I compare and show that these 2 list elements are in fact equal in content?
I have tried this:

print "They are same."

But they dont display the print message due to obvious reasons.
How can I make them equal? I also tried join, concatenation but was not able to make it work.


If prefix_txt[0] is a string 'SEF00', and prefix_confluence[0] is a list containing a unicode version of that same string [u'SEF00'], then you should be able to do the following:

new = prefix_confluence[0][0]
if(prefix_txt[0] == new):
        print "They are same."