1. Home
  2. Data Science
  3. Python
  4. Which of the following methods is used to remove an…

Added 5 May 2024

Which of the following methods is used to remove an element from a set without raising an error if the element is not present?

  1. remove()
  2. pop()
  3. discard() Correct answer
  4. delete()

Correct answer

C. discard()

16 views

MCQSEXAM

Explanation

The discard() method removes an element from a set if it is present, without raising an error if the element is not found.

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs