bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Python/Foundations
Python•Foundations

Python - Remove Set Items

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Python - Remove Set Items?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Order

Put the learning moves in the order that makes the concept easiest to apply.

The return value of the pop() method is the removed item.
You can also use the pop() method to remove an item, but this method will remove a random item, so you cannot be sure what item that gets removed.
To remove an item in a set, use the remove() , or the discard() method.

Remove Item

To remove an item in a set, use the remove() , or the discard() method.

remove()

Note

If the item to remove does not exist, remove() will raise an error.

discard()

Note

If the item to remove does not exist, discard() will NOT raise an error.

You can also use the pop() method to remove an item, but this method will remove a random item, so you cannot be sure what item that gets removed.

The return value of the pop() method is the removed item.

pop()

Note

Sets are unordered , so when using the pop() method, you do not know which item that gets removed.

clear()
del

Previous

Python - Add Set Items

Next

Python - Loop Sets