KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

What would be the output of following code?

str1 = "Hello India"
s1 = str1[1:3]
print(s1)
  1. He
  2. el
  3. Hlo
  4. None of these

Python String Manipulation

2 Likes

Answer

el

Reason — String slicing extracts characters from the starting index up to (but not including) the ending index, so str1[1:3] returns the characters at index 1 and 2, which are e and l.

Answered By

3 Likes


Related Questions