I have a column of 13 digit ISBN numbers (e.g. 1234567890123) saved as strings. To display them in a report, I need to add hyphens, e.g. (123-4-567-89012-3). I use a function to add the dashes before displaying, e.g.
def format_isbn(isbn):
return isbn[0:3] + "-" + isbn[3] + "-" + isbn[4:7] + "-" + isbn[7:12] + "-" + isbn[12]
Is there a simpler way that I'm missing, perhaps by using string formatting?