Robotics & Artificial Intelligence
What would be the output of following code …………… .
str1 = "Hello India"
s1 = str1[1:3]
print(s1)
- He
- el
- Hlo
- None of these
Python String Manipulation
3 Likes
Answer
el
Reason — In Python, string indexing starts from 0. The slice operator [1:3] returns the characters from index 1 up to index 2 (end index is excluded), therefore the output is el.
Answered By
2 Likes
Related Questions
The method used to count the number of characters in a string is …………… .
- length()
- len()
- count()
- None of these
The method used to check that string contains all lower case letter is …………… .
- lower()
- small()
- issmall()
- islower()
What would be the output of following code?
Q1 = "Hello How are you" val = Q1.count("H") print(val)- 1
- 3
- 2
- Error
The method used to check that all characters in a string are alpha numeric is …………… .
- isal()
- isalnum()
- isnum()
- isalphanum()