Pradeep Elance has Published 445 Articles

Count occurrence of all elements of list in a tuple in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:25:26

325 Views

We have a list and tuple. We match the elements of the list with the elements of the tuple and account the number of elements in the table matching with the elements of the list.With CounterWe use the counter function from collections to get the count of every element in ... Read More

Count number of items in a dictionary value that is a list in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:23:15

893 Views

We are given a Dictionary in which the values from the key value pair itself is a list. In this article we will see a how to count the number of items in this list which are present as values in the dictionary.With isinstanceHindi suppose we use isinstance function to ... Read More

Count and display vowels in a string in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:19:57

1K+ Views

Given a string of characters let's analyse how many of the characters are vowels.With setWe first find out all the individual and unique characters and then test if they are present in the string representing the vowels.Example Live DemostringA = "Tutorialspoint is best" print("Given String: ", stringA) vowels = "AaEeIiOoUu" # ... Read More

Converting list string to dictionary in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:18:14

883 Views

Here we have a scenario where if string is presented which has elements in it making it a list. But those elements can also represent a key-value pair making it dictionary. In this article we will see how to take such a list string and make it a dictionary.With split ... Read More

Converting all strings in list to integers in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:16:45

2K+ Views

Sometimes we can have a list containing strings but the strings themselves are numbers and closing quotes. In such a list we want to convert the string elements into actual integers.With int()The int function takes in parameters and converts it to integers if it is already a number. So we ... Read More

Convert two lists into a dictionary in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:15:54

4K+ Views

While a Python list contains a series of values a dictionary on the other hand contains a pair of values which are called key-value pairs. In this article we will take two lists and mark them together to create a Python dictionary.With for and removeWe create two nested for loops. ... Read More

Convert string to DateTime and vice-versa in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:13:41

194 Views

Python has extensive date and time manipulation capabilities.In this article we'll see in how is string with proper format can we converted to a datetime and the vice versa.With strptimeThis strptime function from datetime module can do the conversion from string to datetime by taking appropriate format specifiers.Example Live Demoimport datetime ... Read More

Convert string enclosed list to list in Python

Pradeep Elance

Pradeep Elance

Updated on 04-Jun-2020 11:11:47

514 Views

We may sometime get data which contains strings but the structure of the data inside the stream is a Python list. In this article we will convert string enclosed list to an actual Python list which can be further used in data manipulation.With evalWe know the eval function will give ... Read More

Convert set into a list in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 11:12:20

238 Views

As part of data analysis using Python we may be required to to convert the data container from set to list. In this article we'll see e how to solve this requirement.With listThis is a straightforward approach in which we directly apply the list function on the given set. The ... Read More

Convert number to list of integers in Python

Pradeep Elance

Pradeep Elance

Updated on 20-May-2020 11:10:01

9K+ Views

As part of data manipulation in Python we may sometimes need to convert a given number into a list which contains the digits from that number. In this article we'll see the approaches to achieve this.With list comprehensionIn the below approach we apply the str function to the given number ... Read More

Advertisements