ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(''.join(sorted(set('hello'), key=ord)))
  1. A. lheo
  2. B. ehlo
  3. C. hello
  4. D. olhe

Correct answer: B. ehlo

A set of the characters is {h, e, l, o}, which has no duplicates. Sorting those by code point gives e, h, l, o.

More Python Programming questions

Exams that ask this topic