Python Set remove() MethodPython Functions

Difficulty Level:
Difficulty Level:

The remove() method is used to searches for the given element in the set and removes it.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-

A = {1,4,5,6,11}
print(A)
A.remove(1)
print(A)
A.remove(5)
print(A)
A.remove(11)
print(A)

Output:

{1, 4, 5, 6, 11}
{4, 5, 6, 11}
{4, 6, 11}
{4, 6}

Syntax

set.remove(x)

Parameters

Name Description
x A single element.

Return Value

It doesn’t return any value.

Advertisement

© 2021 Pythonexample.org, all rights reserved. Privacy Policy | Contact Us