ProgrammingModerateTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
words = ['apple', 'bob', 'kayak', 'tree']
print([w for w in words if w == w[::-1]], len(words[1:3]))
  1. A. ['bob', 'kayak'] 2
  2. B. ['bob'] 2
  3. C. ['apple', 'bob', 'kayak'] 3
  4. D. ['kayak'] 3

Correct answer: A. ['bob', 'kayak'] 2

A palindrome reads the same backwards. bob and kayak qualify. words[1:3] has two items.

More Python Programming questions

Exams that ask this topic