Computer Science · Python String Slicing
Identify the logical truth regarding the following palindrome check expression in Python: def is_palindrome(s): return s == s[-1::-1]
- 1It only works correctly for odd-length strings.
- 2It will raise an IndexError on empty strings.
- 3The slice syntax s[-1::-1] is valid, equivalent to s[::-1], and correctly reverses the string, so there is no logical error.✓
- 4The slice syntax is incorrect; it should strictly be s[::-1].
Correct answer
The slice syntax s[-1::-1] is valid, equivalent to s[::-1], and correctly reverses the string, so there is no logical error.
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Python String Slicing?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Python String Slicing