Extract Dictionary Values as a Python List
The dictionary is a collection of data items in the key-value pair and represented by the braces { }. The list is also a data type used to store the date and represented by the braces [ ]. The built-in Python method items() are used to retrieve all the keys and corresponding values. We can print the dictionary’s keys and values by combining the items() method with a for loop....
read more
Randomly select n elements from list in Python
In this article, we will discuss how to randomly select n elements from the list in Python. Before moving on to the approaches let’s discuss Random Module which we are going to use in our approaches....
read more
Find sum and average of List in Python
Given a List. The task is to find the sum and average of the list. The average of the list is defined as the sum of the elements divided by the number of elements....
read more
Extending a list in Python (5 different ways)
In this article, we are going to learn different methods of extending a list in Python....
read more
Python | Add only numeric values present in a list
Given a list containing characters and numbers, the task is to add only numbers from a list. Given below are a few methods to complete a given task....
read more
Python program to sort a list of tuples by second Item
Given a list of tuples, write a Python program to sort the tuples by the second item of each tuple....
read more
Python List methods
Python List Methods are the built-in methods in lists used to perform operations on Python lists/arrays....
read more
Python List Slicing
In Python, list slicing is a common practice and it is the most used technique for programmers to solve efficient problems. Consider a Python list, in order to access a range of elements in a list, you need to slice a list. One way to do this is to use the simple slicing operator i.e. colon(:). With this operator, one can specify where to start the slicing, where to end, and specify the step. List slicing returns a new list from the existing list....
read more
Merge Two Lists in Python
Let’s see how to concatenate two lists using different methods in Python. This operation is useful when we have a number of lists of elements that need to be processed in a similar manner....
read more
Append Element to an Empty List In Python
Appending elements to a list is a common operation in Python, and it’s essential to understand how to add elements to an empty list. In this article, we’ll explore different methods to append items to an empty list and discuss their use cases....
read more
Python map function to find row with maximum number of 1’s
Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s....
read more
Sort even and odd placed elements in increasing order
Given a list N, the task is to sort all the elements in odd and even positions in increasing order. After sorting, we need to put all the odd positioned elements together, then all the even positioned elements.Examples:...
read more