What will be the output of the following code:
my_string = " Hello, World! "
print(my_string.strip())
print(my_string.strip())
A. "Hello, World!"
B. " Hello, World! "
C. "Hello"
D. "Hello, World! "
Answer: Option A
Solution (By Examveda Team)
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!".
Join The Discussion