I’m trying to figure out how to compare two address fields I am pulling from two XML sources. One returns the address in this format:
123 Main St
and the other:
123 MAIN ST
I tried doing something like this:
x = address1 <---first address format i states
y = address2 <---and the second
if x.upper() == y.upper():
print "correct"
else:
print "incorrect"
This does not seem to work, I’m assuming it is because I am trying to set the entire string of the address to uppercase but that wont work with a number. My question is how would I compare two addresses that are returned in different formats, a strait if x = y comparison is not working to compare the addresses.
You can convert both addresses in lower case with .lower() and subsequently compare them.
Lower or Upper case are irrelevant, probably the issue is that you were using the operator “=” instead of “==” causing an assignment.
For example: