?
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.strip())
print(my_string.strip())
Answer & Solution
Correct Answer:
Option
A
The correct answer is Option A: "Hello, World!".
The strip() function in Python is used to remove leading and trailing whitespace (spaces, tabs, and newline characters) from a string. When you call strip() on the string " Hello, World! ", it removes the leading and trailing spaces and returns the modified string "Hello, World!".
The strip() function in Python is used to remove leading and trailing whitespace (spaces, tabs, and newline characters) from a string. When you call strip() on the string " Hello, World! ", it removes the leading and trailing spaces and returns the modified string "Hello, World!".
Join the Discussion
Login to post a comment or share your explanation.
Login