ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print(list('ab') == ['a', 'b'], 'ab' == ['a', 'b'])
  1. A. True True
  2. B. False False
  3. C. False True
  4. D. True False

Correct answer: D. True False

list('ab') builds the list of characters, so it equals ['a', 'b']. A string is never equal to a list.

More Python Programming questions

Exams that ask this topic