ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print('abc'.index('c') + 'abc'.rindex('a'), 'aXbXc'.rsplit('X', 1), 'a b'.title())
  1. A. 3 ['aXb', 'c'] A B
  2. B. 2 ['a', 'bXc'] A B
  3. C. 2 ['aXb', 'c'] A c
  4. D. 2 ['aXb', 'c'] A B

Correct answer: D. 2 ['aXb', 'c'] A B

index('c') is 2 and rindex('a') is 0, giving 2. rsplit with maxsplit 1 splits only at the last X, and title capitalises each word.

More Python Programming questions

Exams that ask this topic