What will be the output of the following Python code snippet? STR = "It is…
2026
What will be the output of the following Python code snippet?
STR = "It is still a test"
print(STR.split('t', 3))
- A.
['I', ' is s', 'ill a test']
- B.
['I', ' is s', 'ill a ', 'es']
- C.
['I', ' is s', 'ill a ', 'est']
- D.
['I', ' is s', 'ill a ', 'es', '']
Attempted by 87 students.
Show answer & explanation
Correct answer: C
The string is "It is still a test".
We apply split('t', 3), which means split the string at character 't' with a maximum of 3 splits.
Step-by-step splitting:
1st 't' → before it is ""
2nd 't' → gives " is s"
3rd 't' → gives "ill a "
Remaining part → "est"
Final Output:
['', ' is s', 'ill a ', 'est']