I'm looking for a way in Python to change, for example, the string "Main St & 1st St" into the string "1st St & Main St".
I know I could do something to the effect of:
intersection = "Main St & 1st St"
intersectionList = intersection.split(" & ")
reversedIntersection = (" & ".join(intersectionList[::-1])).strip()
But it just seems needlessly multi-stepped and I was wondering if there was a more efficient method, a built-in method, etc... that could accomplish the same goal better.
reversedIntersection = (" & ".join(intersection.split(" & ")[::-1])).strip(). There, now you have it in one step.'&'.join(list(reversed(s.split('&'))))list(),reversed()already returns a list