ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print('ab' in 'cabd', '' in 'abc', 'abc'.index(''), len('abc'[3:]), len('abc'[4:]))
  1. A. True False 0 0 0
  2. B. True True 1 0 0
  3. C. True True 0 0 0
  4. D. True True 0 3 0

Correct answer: C. True True 0 0 0

The empty string is a substring of every string, and index('') is 0. Slicing past the end gives an empty result rather than an error.

More Python Programming questions

Exams that ask this topic