Vidyalelo
Python · Q25

Python Built

Programming · Python · question 25

Q25

What will be the output of the following code:my_string = " Hello, World! "print(my_string.strip())

A.
"Hello, World!"
Answer
B.
" Hello, World! "
C.
"Hello"
D.
"Hello, World! "

Answer: Option A

Solution

Answer: Option A
Solution:
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!".