?
What will be the output of the following code:
What will be the output of the following code:
my_string = "Hello, World!"
print(my_string.replace("Hello", "Hi"))
print(my_string.replace("Hello", "Hi"))
Answer & Solution
Correct Answer:
Option
A
The replace() function in Python replaces all occurrences of a specified substring with another substring in a given string. In this case, "Hello" is replaced with "Hi" in the string "Hello, World!", resulting in "Hi, World!".
Join the Discussion
Login to post a comment or share your explanation.
Login