I'm looking for a more pythonic way to replace a known length of placeholders in a string with the values found in a list. They should replace in order and only be used once. For example with the values:
replaceVals = ['foo', 'bar']
origStr = 'I went to the ? to get ?'
I am looking to get:
newStr = 'I went to the foo to get bar'
I was able to get the desired result with the following loop, but I feel like there should be a better way to go about this than using a loop like so.
for i in range(len(replaceVals)):
origStr = origStr.replace('?', replaceVals[i], 1)
") when there is a single source of definitive info?
– roganjosh Feb 01 '19 at 21:49