MCQ Single Best Answer Not Set

QWhat is the output of the following code
aSet = {1, 'PYnative', ['abc', 'xyz'], True}
print(aSet)

ID: #3807 Python Set MCQ 244 views
Question Info
#3807Q ID
Not SetDifficulty
Python Set MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A {1,
  • B {1,
  • C TypeError
Correct Answer: Option C

Explanation

TypeError

If you try to execute the above code you will get a TypeError: unhashable type: 'list'

  • It is true that the set itself is changeable (mutable), but it cannot contain changeable objects such as list and dictionary.
  • Python set can contain unchangeable objects like number, string, tuple etc

Share This Question

Challenge a friend or share with your study group.