- 2
CD,12?
What is the output? print("abcefd".replace("cd","12")) Output: abcefd #Replace simply means to "replace" so I though the code would be ab12ed as just replacing the number strings? Any idea why the answer was abcded?
3 Answers
+ 1
The output is "abcefd" because the string "cd" (both letters need to be together) is not found in "abcefd.
If the original string was "abcd" then the output would be "ab12".
0
Just ran this code and the output was ab12efd. Are you sure the code you're showing us is the original one? Perhaps you removed/added something.
0
Pardone me, Diego! I did make a mistake when transcribing. I'll edit the original post now. Thanks for pointing out my error.



