Question DSA-STR-0004
EasyWhat is the output of this code?
print("hello".find("l"))
- A.
2
- B.
3
- C.
Show answer and explanation
Answer: A
find() returns the index of the first occurrence: 'l' first appears at index 2 (h = 0, e = 1).
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Strings question
What is the output of this code?
print("hello".find("l"))
2
3
Answer: A
find() returns the index of the first occurrence: 'l' first appears at index 2 (h = 0, e = 1).
1
-1