Computer Science
What will be the output of the following code?
str1= "I love Python."
strlen = len(str1)
print(strlen)
- 9
- 29
- 14
- 3
Python String Manipulation
3 Likes
Answer
14
Reason — The len() function returns the length of the string, which includes all characters, spaces, and punctuation. For the string "I love Python.", the length is 14 characters. Thus, len(str1) returns 14.
Answered By
1 Like
Related Questions
Which of the following is the correct syntax of String Slicing?
- String_name [start : end]
- String_name [start : step]
- String_name [step : end]
- String_name [step : start]
What is the correct Python code to display the last four characters of "Digital India"?
- str [-4 :]
- str [4 :]
- str [*4 :]
- str [/4 : ]
What will be the output of the following code?
Str1= 'My name is Nandini ' Str2 = Str1[3:7] strlen = len(Str2) print(strlen)- 4
- 14
- 24
- 34
Which method removes all the trailing whitespaces from the right of the string?
- tolower()
- upper()
- Istrip()
- rstrip()