Tag: Remove
Python : How to remove element from a list by value or Index | remove() vs pop() vs del
In this article we will discuss different ways to remove an elements from list. Remove an element from List by value using list.remove() Python’s list provides a member function to remove an element from list i.e. Advertisements list.remove(value) It removes the first occurrence of given element from the list. For example, Frequently Asked: Convert a …
Python : How to remove element from a list by value or Index | remove() vs pop() vs delRead More
Python : How to remove multiple elements from list ?
In this article we will discuss different ways to remove multiple elements from list. Suppose we have a list of numbers i.e. # List of Numbers listOfnum = [12, 44, 56, 45, 34, 3, 4, 33, 44] Now we want to remove all the numbers from list, which are multiple of 3. Advertisements Remove multiple …
Python : How to remove multiple elements from list ?Read More
Python : How to remove files by matching pattern | wildcards | certain extensions only ?
In this article we will discuss how to delete few files from a directory based on matching pattern or wildcard. Suppose we have a directory that contains some log files and some text files and we want to delete all .txt files from that directory i.e. files that ends with string “.txt”. Let’s discuss how …
Python : How to remove files by matching pattern | wildcards | certain extensions only ?Read More
Python : How to remove a file if exists and handle errors | os.remove() | os.ulink()
In this article we will discuss how to remove a file if only it exists and how to handle other types of exceptions using os.remove() & os.ulink(). How to remove a file using os.remove() python ‘s os module provides a function to remove the file i.e. Advertisements os.remove(path_of_file) It accepts the file path as argument …
Python : How to remove a file if exists and handle errors | os.remove() | os.ulink()Read More
Python : How to remove characters from a string by Index ?
In this article we will discuss how to remove characters from a string at specific index position or in a given range of indices. We can remove characters from string by slicing the string into pieces and then joining back those pieces. Advertisements String Slicing In Python strings are immutable i.e. we can not modify …
Python : How to remove characters from a string by Index ?Read More
np.delete(): Remove items/rows/columns from Numpy Array
In this article, we will discuss how to remove elements from a 1D or 2D Numpy Array by index position using numpy.delete(). Then we will also see how to remove rows and columns from 2D numpy array. Delete elements / rows / columns from Numpy Array using np.delete() Table of Contents np.delete() – Overview Delete …
np.delete(): Remove items/rows/columns from Numpy ArrayRead More
How to Stop & remove all or running or stopped docker containers ?
In this article we will discuss how remove all docker containers or only running or stopped containers. Suppose we have 6 containers in our docker engine out of which 3 are running and 3 are stopped i.e. Advertisements PS C:Windowssystem32> docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4188498ee191 ubuntu “/bin/bash” 7 …
How to Stop & remove all or running or stopped docker containers ?Read More
Docker : How to Stop & Remove a running container by ID or Name ?
In this article we will discuss how to stop and remove a running container by filtering on ID and Name. To completely remove a running container, first we have to stop it and then remove it. Advertisements How to stop a running docker container ? Suppose we have a running container whose Status is ‘UP’ …
Docker : How to Stop & Remove a running container by ID or Name ?Read More
Python Set: remove() vs discard() vs pop()
In this article we will learn about three different functions to remove elements from a set in python i.e. remove(), discard() and pop(). set.remove() In python, set class provides a member function remove() to delete an element from the set i.e. Advertisements set.remove(element) It removes the given element from the set. If the element is …
Python Set: Remove single or multiple elements from a set?
In this article we will discuss different ways to remove single or multiple elements from a set in python. Remove a single element from a set Suppose we have a set of numbers in python, Advertisements # Create a set of numbers set_of_num = {1, 2, 11, 6, 7, 4, 5} print(‘Original Set: ‘) print(set_of_num) …
Python Set: Remove single or multiple elements from a set?Read More