96. Problem to get the length of each word and add it as dictionary

In this Python list program, we will take a user input as a list and get length of each word and add it as a dictionary with the help of the below-given steps.

Get length of each word in list:

Steps to solve the program
  1. Take a list containing words as input.
  2. Create an empty dictionary and a list.
  3. Use for loop to iterate over each word in the given list and add the word as key in the dictionary and its length as value.
  4. Add that dictionary to the list.
  5. Print the list to see the output.
				
					#Input list
list1 = ["Hello", "student", "are", "learning", "Python", "Its", "Python", "Language"]
dictionary = dict()
list2 = []

for value in list1:
    dictionary[value]=len(value)
list2.append(dictionary)

#Printing list
print(list2));
				
			

Output :

				
					[{'Hello': 5, 'student': 7, 'are': 3, 'learning': 8, 
'Python': 6, 'Its': 3, 'Language': 8}]
				
			

Related Articles

Python program to remove duplicate dictionaries from the given list.

Python program to decode a run-length encoded given list.

Python program to round every number in a given list of numbers and print the total sum of the list.

Python Program to get the Median of all the elements from the list.

Python Program to get the Standard deviation of the list element.

Python program to convert all numbers to binary format from a given list.

 

 

 

Remove the 2nd character of each word from list

Remove duplicate dictionaries from the list

Leave a Comment