Single Choice
Not Set
QWhat is the output of the following code
sampleSet = {"Yellow", "Orange", "Black"}
print(sampleSet[1])
ID: #3808
Python Set MCQ
232 views
Question Info
#3808Q ID
Not SetDifficulty
Python Set MCQTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
Syntax Error
We cannot access items in a set by referring to an index because the ‘set’ object does support indexing (the set is unordered). if you try to access items using the index, you will get TypeError: ‘set’ object does not support indexing.
Use a for loop to access set items.
sampleSet = {"Yellow", "Orange", "Black"}
for item in sampleSet:
print(item)
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic