I am getting two strings in the following way which contain integer values. I have tried all options but always got False as a result.
string1 = element.__dict__.get('layer') # '7'
temp_string2,temp_string3=temp_key.split(':') # temp_key = '7:12'
if string1 == temp_string2:
print "data found"
I did not get True although both contain the same value. Can I have some input regarding this?
Based on what I saw in the comment stream
Its evident, you are comparing an integer with a string.
If
print repr(string1), returns7andprint repr(temp_string2)returns"7"thenstring1, which isshould be an integer
So you have to convert
string1tointegerbefore comparingor convert it to a string after retrieving the value from dictionary
Strangely enough, its a very unconventional way of accessing a the get method of the dict, instead you could have simply done a member referencing with
.notation