Python – Check if two lists are identical This article deals with the task of ways to check if two unordered list contains exact similar elements in exact similar position, i.e to check if two lists are exactly equal. This is quite a useful utility and can be used in day-day programming. Method 1… Continue reading Python – Check if two lists are identical
Tag: Python list-program
Remove multiple elements from a list in Python
Remove multiple elements from a list in Python Given a list of numbers, write a Python program to remove multiple elements from a list based on the given condition. Example: Input: [12, 15, 3, 10] Output: Remove = [12, 3], New_List = [15, 10] Input: [11, 5, 17, 18, 23, 50] Output: Remove =… Continue reading Remove multiple elements from a list in Python
Python – Remove first element of list
Python – Remove first element of list Queue data structure is very well known data structure, lists in Python usually appends the elements to the end of the list. For implementing a queue data structure, it is essential to be able to remove the front element from a list. Let’s discuss the ways of removing… Continue reading Python – Remove first element of list
Python – Intersection of two lists
Python – Intersection of two lists Intersection of two list means we need to take all those elements which are common to both of the initial lists and store them into another list. Now there are various ways in Python, through which we can perform the Intersection of the lists. Examples: Input : lst1… Continue reading Python – Intersection of two lists
Reversing a List in Python
Reversing a List in Python Python provides us with various ways of reversing a list. We will go through few of the many techniques on how a list in python can be reversed. Examples: Input : list = [10, 11, 12, 13, 14, 15] Output : [15, 14, 13, 12, 11, 10] Input : list… Continue reading Reversing a List in Python
How to concatenate two lists in Python
Ways to concatenate two lists in Python Let’s see how to concatenate two lists using different methods in Python. This operation is useful when we have numbers of lists of elements which needs to be processed in a similar manner. Method #1 : Using Naive Method In this method, we traverse the second list and… Continue reading How to concatenate two lists in Python
Python – Multiply all numbers in the list (All different ways)
Python – Multiply all numbers in the list Given a list, print the value obtained after multiplying all numbers in a list. Examples: Input : list1 = [1, 2, 3] Output : 6 Explanation: 1*2*3=6 Input : list1 = [3, 2, 4] Output : 24 Method 1: Traversal Initialize the value of the… Continue reading Python – Multiply all numbers in the list (All different ways)
Python List sort() method
Python List sort() method Python list sort() function can be used to sort a List in ascending, descending, or user-defined order. To Sort the List in Ascending Order Syntax: List_name.sort() This will sort the given list in ascending order. This function can be used to sort a list of integers, floating-point numbers, strings, and others.… Continue reading Python List sort() method
Python – Converting all strings in list to integers
Python – Converting all strings in list to integers Interconversion between data types is facilitated by python libraries quite easily. But the problem of converting the entire list of string to integers is quite common in development domain. Let’s discuss few ways to solve this particular problem. Method #1 : Naive Method This is most… Continue reading Python – Converting all strings in list to integers
Find size of a list in Python
Find size of a list in Python In Python, List is a collection data-type which is ordered and changeable. A list can have duplicate entry as well. Here, the task is find the number of entries in a list. See the examples below. Examples: Input : a = [1, 2, 3, 1, 2, 3] Output… Continue reading Find size of a list in Python