I have two types of addresses:
Unit 5, 123 Fake Street Drive
123 Fake St Dr, Unit 5
How can I use Python to compare the two addresses by the numbers?
For example:
Unit 5, 123 Fake Street Drive -> [5,123]
123 Fake St Dr, Unit 5 -> [123,5]
TRUE
123 Fake Street Drive -> [123]
123 Fake St Dr, Unit 5 -> [123,5]
FALSE
Unit 5, 155 Fake Street Drive -> [155,5]
123 Fake St Dr, Unit 5 -> [123,5]
FALSE
All I have now is:
if bool(set([int(s) for s in address.split() if s.isdigit()]) & set([int(s) for s in address2.split() if s.isdigit()])):
I want to find out if one list of numbers is the same as another list of numbers regardless of the order.
==, that should work.Unit 1, 2 Streetand2 A completely different street, unit 1the output should beFalse?"1, 2".split()you'll get1,: not all digits: fails.