Pradeep Elance has Published 337 Articles

Convert a list of multiple integers into a single integer in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:38:55

3K+ Views

Sometimes we may have a list whose elements are integers. There may be a need to combine all these elements and create a single integer out of it. In this article we will explore the ways to do that.With joinThe join method can Join all items in a tuple into ... Read More

Convert a list into tuple of lists in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:37:15

609 Views

Converting one data container into another in python is a frequent requirement. In this article we will take a list and convert into a tuple where each element of the tuple is also a list.With tupleWe can apply the tuple function straight to the list. But we have to also ... Read More

Consecutive elements pairing in list in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:34:18

804 Views

During data analysis using python, we may come across a need to pair-up the consecutive elements of a list. In this article we will see the various ways to achieve this.With index and rangeWe will design an expression to put the consecutive indexes of the list elements together. And then ... Read More

Consecutive element maximum product in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:31:06

378 Views

Python has great libraries to manipulate data. We may come across a need to find the maximum product of two consecutive numbers which are part of the big string. In this article we will see the ways to achieve that.With zip and maxWe convert the string into a list. Then ... Read More

Concatenate two lists element-wise in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:28:39

1K+ Views

Pyhton has great data manipulation features. In this article we will see how to combine the elements from two lists in the same order as they are present in the lists.With zipThe zip function can take in the two lists as parameters and concatenate them. We design a for loop ... Read More

Combining values from dictionary of list in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:26:12

628 Views

Let’s say we have a python dictionary which has lists as it values in the key value pairs. We need to create a list which will represent all possible combinations of the keys and values from the given lists.With sorted and productThe product function from itertools can be used to ... Read More

Combining two sorted lists in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:21:37

408 Views

Lists are one of the most extensively used python data structures. In this article we will see how to combine the elements of two lists and produce the final output in a sorted manner.With + and sortedThe + operator can join the elements of two lists into one. Then we ... Read More

Combining tuples in list of tuples in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:20:36

672 Views

For data analysis, we sometimes take a combination of data structures available in python. A list can contain tuples as its elements. In this article we will see how we can combine each element of a tuple with another given element and produce a list tuple combination.With for loopIn the ... Read More

Checking triangular inequality on list of lists in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:15:50

387 Views

The sum of two sides of a triangle is always greater than the third side. This is called triangle inequality. Python list of lists we will identify those sublists where the triangle inequality holds good.With for and >We will first get all the sublists sorted. Then for each sublist we ... Read More

Checking if starting digits are similar in list in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 10:09:50

406 Views

Sometimes in a given Python list we may be interested only in the first digit of each element in the list. In this article we will check if the first digit of all the elements in a list are same or not.With set and mapSet in Python does not allow ... Read More

Advertisements