ExamVeda
Login
Home
Python Built In Functions
?

What will be the output of the following code:
my_string = "Hello, World!"
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!".
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.