0
Which approach should I take?
If I want to replace a word in a sentenance with another word. So should I take the approach of a for loop for that or .sub() method?
3 Antworten
+ 1
I would use:
string = string.replace("word1", "word2")
+ 1
Thanks. I never knew about this method.
0
I think the .sub() method is better due to its easy and short syntax. But at first it is confusing.