Category: List
Python : How to Insert an element at specific index in List ?
In this article we will discuss how to insert an element in list at specific position. Inserting an element in list at specific index using list.insert() In python list provides a member function insert() i.e. Advertisements list.insert(position, element) It accepts a position and an element and inserts the element at given position in the list. …
Python : How to Insert an element at specific index in List ?Read More
Python : How to Remove Duplicates from a List
In this article we will discuss different ways to remove duplicate elements from a list in python. List : Containing duplicate elements : Advertisements [10, 2, 45, 3, 5, 7, 2, 10, 45, 8, 10] List : After removing duplicate elements, [10, 2, 45, 3, 5, 7, 8] Let’s see how to do that, Frequently …
Python : Join / Merge lists ( two or more)
In this article we will discuss different ways to Merge / Join two or more lists in python. Table of Contents Join / Merge two lists in python using + operator. Join / Merge two lists in python using list.extend(). Join / Merge two lists in python using unpacking. Join / Merge two lists in …
Convert list to string in python using join() / reduce() / map()
In this article we will discuss different ways to convert list to string. Convert list to string in python using join() in python In python string class provides a function join() i.e. Advertisements string.join(iterable) join() function accepts an iterable sequence like list or tuple etc as an argument and then joins all items in this …
Convert list to string in python using join() / reduce() / map()Read More
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 : Get number of elements in a list, lists of lists or nested list
In this article we will discuss different ways to count number of elements in a flat list, lists of lists or nested lists. Count elements in a flat list Suppose we have a list i.e. Advertisements # List of strings listOfElems = [‘Hello’, ‘Ok’, ‘is’, ‘Ok’, ‘test’, ‘this’, ‘is’, ‘a’, ‘test’] To count the elements …
Python : Get number of elements in a list, lists of lists or nested listRead More
Python : Count elements in a list that satisfy certain conditions
In this example we will discuss 4 different ways to count number of elements in a list that satisfy certain conditions. Suppose we have a list of numbers i.e. Advertisements # List of numbers listOfElems = [11, 22, 33, 45, 66, 77, 88, 99, 101] We want to count number of elements in the list …
Python : Count elements in a list that satisfy certain conditionsRead More
Python : Convert list of lists or nested list to flat list
In this article we will discuss different ways to convert a list of lists or nested lists to a single flat list. Convert a list of lists to a flat list Suppose we have a list of lists i.e. Advertisements # List of list listOfList = [ [1, 2, 3, 4, 5], [11, 22, 33, …
Python : Convert list of lists or nested list to flat listRead More
Python: Find duplicates in a list with frequency count & index positions
In this article, we will discuss how to find duplicates in a list along with their frequency count and their index positions in the list. Let’s do this step by step, Advertisements Step 1: Get duplicate elements in a list with a frequency count Suppose we have a list of strings i.e. # List of …
Python: Find duplicates in a list with frequency count & index positionsRead More