← 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?
- A.s == s[1:]
- B.s == s[::-1]
- C.s == s.reverse()
- 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 →