Mar-29-2020, 11:05 PM
In the second code, str.replace() replaces all instances of "NOUN" on the first iteration of the loop with the selected noun from the if statement. Conversely, the first code inserts the word at the index points, allowing for different nouns to be selected. Is that the performance difference you're inquiring about?