I've been trying for hours to do this in Python and I don't know what else to do. I have a string similar to this:
title = "Marielizabeth's Diary Chapter 9"
I want to get the number after the word "chapter" and then put a 0 in front of it: "Marielizabeth's Diary Chapter 09". I can't use title.replace because I don't know what I'll get. I only know that the number is after the word "chapter".
chapter = title.split('Chapter ', 1)
for char in chapter:
print char
But it doesn't work. How can I do this?
Final solution:
title = "Marielizabeth's Diary Chapter 9"
re.sub('Chapter (\d$)', lambda m: "0" + m.group(1), title)