ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
word = 'Level'
print(word.lower() == word.lower()[::-1], word == word[::-1], word.casefold() == 'level')
  1. A. True False False
  2. B. True False True
  3. C. False False True
  4. D. True True True

Correct answer: B. True False True

lower() makes the comparison case-insensitive, so the palindrome check on 'level' is True. The raw word Level is not equal to its reverse, because the first letter is uppercase. casefold gives 'level'.

More Python Programming questions

Exams that ask this topic