Assuming you are taking the approach you have started with, I would recommend defining a functiont that seeks for the last example of a substring in a string:
def findLast(s, target):
prev = 0
pos = s.find(target, prev)
while pos > -1:
prev = pos
pos = s.find(target, prev + len(target))
return prev
However, as it happens, Python has a set of standard libraries for parsing XML-based markup, which SVG certainly is. While this may be more than you need right now, if you expect to be doing a lot more of this sort of thing, you might want to look into xml.etree.ElementTree or xml.parse.expat.