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

Pradeep Elance
Published on 04-Jun-2020 14:51:38
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

Smallest Sufficient Team in Pyhton

Arnab Chakraborty
Published on 04-Jun-2020 14:49:52
Suppose for a project we have a list of required skills called req_skills, and a list of people. Here i-th people people[i] contains a list of skills that person has.Now suppose a sufficient team is defined as a set of people such that for every required skill in req_skills, there ... Read More

Count and display vowels in a string in Python

Pradeep Elance
Published on 04-Jun-2020 14:49:26
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: \n", stringA) vowels = "AaEeIiOoUu" # ... Read More

Parsing A Boolean Expression in Python

Arnab Chakraborty
Published on 04-Jun-2020 14:47:31
Suppose we have a boolean expression, we have to find the result after evaluating that expression.An expression can either be −"t", evaluating to True;"f", evaluating to False;"!(expression)", evaluating to the logical NOT of the inner expression;"&(expr1, expr2, ...)", evaluating to the logical AND of 2 or more inner expressions;"|(expr1, expr2, ... Read More

Converting list string to dictionary in Python

Pradeep Elance
Published on 04-Jun-2020 14:47:24
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
Published on 04-Jun-2020 14:45:44
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
Published on 04-Jun-2020 14:44:48
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

Shortest Common Supersequence in C++

Arnab Chakraborty
Published on 04-Jun-2020 14:43:28
Suppose we have two strings str1 and str2, we have to find the shortest string that has both str1 and str2 as subsequences. There may be more than one results, so we will return only one of them.As you know a string S is called a subsequence of string T ... Read More

Convert string to DateTime and vice-versa in Python

Pradeep Elance
Published on 04-Jun-2020 14:43:12
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
Published on 04-Jun-2020 14:41:07
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
Advertisements