Robotics & Artificial Intelligence

What would be the output of following code?

information = "I am studying in class X !"
val = information.find("studying")
print("The index is: ", val)
  1. 5
  2. 6
  3. 7
  4. Error

Python String Manipulation

2 Likes

Answer

5

Reason — The find() function returns the index of the first occurrence of the specified value. In the given string, the word "studying" starts at index 5, therefore the output is 5.

Answered By

2 Likes


Related Questions