The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
Question #720
my_set = {1, 2, 3}
my_set.discard(4)
print(my_set)
The set discard() method does not throw an exception if the item to be discarded is not present in the list. (w3schools.com/python/ref_set_discard.asp)
What is the output of the code snippet below?
— The Python Quiz (@thepythonquiz) May 17, 2021
my_set = {1, 2, 3}
my_set.discard(4)
print(my_set)
It will throw a KeyError exception.
{}
{1, 2, 3}
{1, 2, 3, 4}
None of the above
π Comment the answer, like and retweet! #python
Question difficulty: π΅π΅π΅π΅π΅
Similar questions: