Tutorial Gateway

  • C Language
  • Java
  • R
  • SQL
  • MySQL
  • Python
  • BI Tools
    • Informatica
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • QlikView
  • Js

Python set remove method

by suresh

Python set remove is one of the set method, which is used to remove an item from the given set. In this article, we will show you, How to use this Python remove set function with practical examples.

TIP: Please refer sets article to understand everything about Sets.

Python set remove syntax

The basic syntax behind this remove function is:

set_Name.remove(element)

Python set remove Example 1

The set remove function helps you to remove any item from a given set. This is very useful function, if you know the item name that you want to delete. Below code removes or delete 30 from an integer set called  removeSet

# Python set remove method

removeSet = {10, 25, 30, 45, 50}
print("\nOld Set Items = ", removeSet)

# Python Remove Set Item
removeSet.remove(30)
print("After Remove Method - Set Items = ", removeSet)

OUTPUT

Python set remove method 1

Let me show you another set remove method example. So that, you can get the complete idea.

How to remove set item in Python Example 2

In this example, we declared a string set. Next, we used this set remove function on the string set. Here, remove function will remove cherry from the fruits set.

# Python set remove method

removeSet = {'apple', 'Mango', 'cherry', 'kiwi', 'orange', 'banana'}
print("\nOld Set Items = ", removeSet)

# Python Remove Set Item
removeSet.remove('cherry')
print("After Remove Method = ", removeSet)

OUTPUT

Python set remove method 2

Thank You for Visiting Our Blog

Placed Under: Python

Trending Posts

SQL @@PACK_SENT

SQL ALIAS

Informatica Workflow Monitor

Python String Count

Java String replaceFirst Method

Sorter Transformation in Informatica

Router Transformation in Informatica

MySQL GREATEST Function

Java Program to find First Digit of a Number

Add Row Numbers to SSRS Report

  • C Programs
  • Java Programs
  • SQL FAQ’s
  • Python Programs
  • SSIS
  • Tableau
  • JavaScript

Copyright © 2019 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy