🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Python Strings: all 15 questions

Quiz: Python Strings · Question 15 of 15

A string is a palindrome if it reads the same both ways. Which condition checks this for s?

A string is a palindrome if it reads the same both ways. Which condition checks this for s?

  1. A.s == s[1:]
  2. B.s == s[::-1]
  3. C.s == s.reverse()
  4. D.s[0] == s[1]
Answer & explanation

Correct answer: s == s[::-1]

s[::-1] is s reversed. Strings have no reverse() method.

Can you get the rest right without peeking?

Take the timed Quiz: Python Strings quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →