arrow
arrow
arrow
Why do we use negative slicing in Python strings?
Question



Why do we use negative slicing in Python strings?

A.

To reverse the string

B.

To extract elements from the end

C.

To add elements to a string

D.

To find the length of the string

E.

To replace characters in a string

Correct option is B

Negative slicing is used to extract elements from the end of a string.
Important Key Points:
1. Negative slicing in Python allows accessing string elements starting from the end of the string using negative indices.
2. For example, "Python"[-1] returns 'n', the last character of the string.
3. Using [::-1] as a slicing pattern reverses the string completely.
Knowledge Booster:
· Reversing a string is achieved using [::-1], but negative slicing itself doesn’t reverse the string.
· Adding elements to a string is not possible, as strings in Python are immutable.
· Finding the length of a string is done using the len() function, not slicing.
· Replacing characters in a string is done using the replace() method.

Free Tests

Free
Must Attempt
Video Solutions

RBI Assistant Pre 2026 Full Mock Test -01

languageIcon English
  • pdpQsnIcon100 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon60 Mins
languageIcon English
Free
Must Attempt
Video Solutions

RBI Asst Prelims 2026 : Reasoning Section Test 01

languageIcon English
  • pdpQsnIcon35 Questions
  • pdpsheetsIcon35 Marks
  • timerIcon20 Mins
languageIcon English
Free
Must Attempt
Video Solutions

RBI Office Attendant 2026 Full Mock Test - 01

languageIcon English
  • pdpQsnIcon120 Questions
  • pdpsheetsIcon120 Marks
  • timerIcon90 Mins
languageIcon English
test-prime-package

Access ‘IBPS SO IT Officer’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
354k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow