I'm wondering how to use a list to format multiple of the same keyword in Python 3.4. The way I have it set up is a user can pass in a string that has multiple keywords for names that the program will generate in their place, and the result should be a sentence with the keywords replaced with names.
I have already created a method to generate the names based on how many the program sees in the strings the user passes in, but cannot replace them at once because of the nature of the string. Since the string has multiple of the same keyword (for example {name}), I need to be able to replace each one of them with a unique string. Is that possible in Python 3.4?
The string the user passes in could be
"{name} had a wonderful day at the park, but then {name} came and ruined it"
and after the program has generated the names it should be
"John had a wonderful day at the park, but then Bob came and ruined it"
Cheers.
EDIT: To add, I didn't find anything about using lists or having multiple keywords but unique replacements, so if I have to do it another way than replace it's OK too.