ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print('abc'.find(''), 'abc'.count(''), ''.split(), ''.split(','))
  1. A. 1 4 [] ['']
  2. B. 0 4 [] ['']
  3. C. -1 4 ['a'] ['']
  4. D. 0 3 [] []

Correct answer: B. 0 4 [] ['']

The empty string is found at index 0 and occurs four times in a three-character string. split() with no argument returns an empty list for empty text, while split(',') returns one empty string.

More Python Programming questions

Exams that ask this topic