I am really confused about the replace python method. i used the replace function in two instances but the output is really confusing. This is the code below
story = 'there was once an old woman'
story2 = story.replace('an', 'a') .replace('old', 'young'))
print(story2)
and when i run the code below. the output becomes. there was once a young woma someone please tell me why was deleted from the woman.
Your code does not match the image. The code is correct, but the code from the image is incorrect.
The second n was removed from woman because
.replace()replaces all occurrences. To only replaceninstances, pass a number.You can chain the
.replace()functions just fine.