Pradeep Elance has Published 417 Articles

Check if two lists are identical in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:47:00

614 Views

In python data analysis, we may come across situation when we need to compare two lists and find out if they are identical meaning having same elements or not.Exmple Live DemolistA = ['Mon', 'Tue', 'Wed', 'Thu'] listB = ['Mon', 'Wed', 'Tue', 'Thu'] # Given lists print("Given listA: ", listA) print("Given listB: ... Read More

Check if substring present in string in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:44:33

263 Views

In python data analysis we may come across a scenario to check if a given substring is part of a bigger string. We will achieve this through the following programs.With findThe find function finds the first occurrence of the specified value. If the value is not found then it returns ... Read More

Check if list is strictly increasing in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:39:04

1K+ Views

Given a list, we may need to check for the sequence of its elements. In this article we will find out if the elements present in the list are in a strictly increasing order. Below programs achieve that objective.With all and zipIn this approach we first slice each element compare ... Read More

Check if list is sorted or not in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:35:11

6K+ Views

Lists are the most widely used data collectios in python. We may come across situation when we need to know if the given list is already sorted or not. In this article we will see the approaches to achieve this.With sortWe take a copy of the given list, apply sort ... Read More

Check if list contains consecutive numbers in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:32:52

3K+ Views

Depending on the needs of our data analysis we may need to check for presence of sequential numbers in a python data container. In the below programs we find out if among the elements of Alist, there are any consecutive numbers.With range and sortedThe sorted function will rearrange the elements ... Read More

Check if given string can be formed by concatenating string elements of list in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:30:47

567 Views

We sometimes need to check if a required string can be formed from many number of strings that are present in a list. It also should not matter in what order the strings are present in the list which have to be joined to get the required string.With permutationsFrom itertools ... Read More

Check if given multiple keys exist in a dictionary in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:27:28

2K+ Views

During data analysis using python, we may need to verify if a couple of values exist as keys in a dictionary. So that the next part of the analysis can only be used with the keys that are part of the given values. In this article we will see how ... Read More

Check if element is present in tuple of tuples in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:24:13

1K+ Views

Python Tuples can be nested. We can have a tuple whose elements are also tuples. In this article we will see how to find out if a given value is present as an element in a tuple of tuples.With anyThe any function can be used to check if a given ... Read More

Check if element exists in list of lists in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:19:28

2K+ Views

Lists can be nested, means the elements of a list are themselves lists. In this article we will see how to find out if a given element is present in the sublist which are themselves elements in the bigger list.With anyWe first search if an element is present in the ... Read More

Check if a list exists in given list of lists in Python

Pradeep Elance

Pradeep Elance

Updated on 13-May-2020 14:14:28

840 Views

Lists can be nested, means the elements of a list are themselves lists. In this article we will see how to find out if a given list is present as an element in the outer bigger list.With inThis is a very simple and straight forward method. We use the in ... Read More

Advertisements