mutable set member function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

mutable set member function?

Hello, I got this question Which of these is a mutable set member function? a) remove() b)extend() c)del() d)append() I am not sure how this applies in real life scenario? to me whenever you perform remove,extend,del and append will change the set so why only remove is correct?

19th Nov 2019, 1:27 PM
THEGreatGatsby
THEGreatGatsby - avatar
3 Answers
+ 3
Hi ! extend() adds one list's value in the END of the list, and order is saved, that's why you can't use it in set (sets are unordered). append() is the same, but it adds one element, again, to the END of the list. del() removes some element from the list by it's index, sets can't be indexed (unordered). remove() removes some element from a sequence, that's why you can use it in sets, you don't need the order of sequence to remove from it any element.
19th Nov 2019, 1:31 PM
Asman-H
Asman-H - avatar
+ 1
I edited, check it out, truly forgot :)
19th Nov 2019, 1:42 PM
Asman-H
Asman-H - avatar
0
how about del?
19th Nov 2019, 1:42 PM
THEGreatGatsby
THEGreatGatsby - avatar