ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print('ab' in ['ab', 'cd'], 'ab' in 'cdab', [] in [[]])
  1. A. True False True
  2. B. True True True
  3. C. False True True
  4. D. True True False

Correct answer: B. True True True

in on a list checks equality with each item, and in on a string checks for a substring. [] equals the empty list inside [[]].

More Python Programming questions

Exams that ask this topic