ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print('a-b-c-d'.rsplit('-', 2), 'a-b-c-d'.split('-', 1))
  1. A. ['a-b', 'c'] ['a', 'b-c-d']
  2. B. ['a-b', 'c', 'd'] ['a', 'b-c-d']
  3. C. ['a-b', 'c', 'd'] ['a', 'b-c']
  4. D. ['a-b', 'c'] ['a', 'b-c']

Correct answer: B. ['a-b', 'c', 'd'] ['a', 'b-c-d']

rsplit with maxsplit 2 splits from the right and gives three parts. split with maxsplit 1 splits only at the first separator.

More Python Programming questions

Exams that ask this topic