Question Detail

COS 102 Advanced Text Processing Objective Question

Question

What is the primary purpose of using negative slicing limits in Python?
Options
A To reverse the entire string easily.
B To count characters from the end of the string without starting from zero.
Correct Answer
C To exclude specific characters from the middle of the string.
D To perform mathematical operations within the slice.
Correct Answer

Option B is the correct answer.

Detailed Explanation

The document explains: 'What if you want to pull characters from the end of a long text string without counting from zero?' Negative slicing limits provide a convenient way to reference characters from the end of a string.

Hint

Think about counting positions from the right side of the string.

Question Info