Examveda

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

This Question Belongs to Python Program >> Python Built In Functions

Join The Discussion

Related Questions on Python Built In Functions