What will be the output of `sorted({'b': 2, 'a': 1})`?

  1. ['a', 'b']
  2. [1, 2]
  3. ['b', 'a']
  4. {'a': 1, 'b': 2}
Correct answer ['a', 'b']

Explanation

`sorted()` returns the sorted list of dictionary keys.

Update: Admin added a tag on this question

Topics

By Admin · · 31 views