Data Structures & AlgorithmsModerateTCS NQT Digital · Python semantics

Problem: What does the following print?

Problem: What does the following print?
print(list('abc')[::-1] == ['c', 'b', 'a'], 'abc'.index('c'))
What is printed?
  1. A. True 2
  2. B. False 2
  3. C. True 0
  4. D. True 1

Correct answer: A. True 2

Reversing the list gives ['c', 'b', 'a'], and 'c' sits at index 2 in 'abc'.

More Coding Interview Problems questions

Exams that ask this topic