Computer Science
Which functions would you choose to use to remove leading and trailing white spaces from a given string?
Python String Manipulation
23 Likes
Answer
lstrip() removes leading white-spaces, rstrip() removes trailing white-spaces and strip() removes leading and trailing white-spaces from a given string.
Answered By
16 Likes
Related Questions
What happens when from a string slice you skip the start and/or end values of the slice?
What would the following expressions return?
- "Hello World".upper( ).lower( )
- "Hello World".lower( ).upper( )
- "Hello World".find("Wor", 1, 6)
- "Hello World".find("Wor")
- "Hello World".find("wor")
- "Hello World".isalpha( )
- "Hello World".isalnum( )
- "1234".isdigit( )
- "123FGH".isdigit( )
Try to find out if for any case, the string functions isalnum( ) and isalpha( ) return the same result
Suggest appropriate functions for the following tasks:
- To check whether the string contains digits
- To find for the occurrence a string within another string
- To convert the first letter of a string to upper case
- to capitalize all the letters of the string
- to check whether all letters of the string are in capital letters
- to remove from right of a string all string-combinations from a given set of letters
- to remove all white spaces from the beginning of a string