Skip to content
Question

Q.Select the correct output of the code : S="Amrit Mahotsav @ 75" A=S.split(" ",2) print(A)

(a) ('Amrit', 'Mahotsav', '@', '75')
(b) ['Amrit', 'Mahotsav', '@ 75']
(c) ('Amrit', 'Mahotsav', '@ 75')
(d) ['Amrit', 'Mahotsav', '@', '75']
CBSECBSE Class XII Board 2023MCQ· 1mImportance★★★★★
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

The split(" ",2) method splits the string into at most three parts using the space character as the delimiter, producing a list with the first two spaces as split points and the remainder as the third element.

Let’s walk through what happens when Python runs this code. The string S = "Amrit Mahotsav @ 75" contains three spaces — one after "Amrit", one after "Mahotsav", and one before "75". The method split(" ",2) is called with two arguments: the delimiter (a single space) and the maximum number of splits (2).

The key idea is that split with a maxsplit argument does not split the string into all possible pieces. Instead, it performs exactly that many splits, starting from the left, and then lumps everything after the last split into one final piece. So with maxsplit=2, Python will split at the first space and at the second space, but not at the third space. After the second split, whatever remains of the string — including any further spaces — becomes the third element of the resulting list.

Let’s trace it:

  • First split: at the space after "Amrit". We get "Amrit" and the rest: "Mahotsav @ 75".
  • Second split: at the space after "Mahotsav". We get "Mahotsav" and the remainder: "@ 75".

The remainder "@ 75" is not split further because we have already used up both allowed splits. So the final result is a list with three elements: ['Amrit', 'Mahotsav', '@ 75'].

Note

The split method always returns a list, not a tuple. Options (a) and (c) show tuples (with round brackets), so they are incorrect on that ground alone.

Now look at the options:

  • (a) ('Amrit', 'Mahotsav', '@', '75') — This is a tuple with four elements. Wrong on two counts: it’s a tuple, and it has four items. …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.