92. Problem to create a dictionary from a sublist in given list

In this Python list program, we will take a list of sublists as input and create a dictionary from a sublist in given list with the help of the below-given steps.

Create dictionary from a sublist:

Steps to solve the program
  1. Take a list of sublists as input.
  2. Convert the given list into a dictionary using dict() and assign it to a variable.
  3. Print the variable to see the result.
				
					#Input list
list1 = [["a", 5], ["b", 8], ["c", 11], ["d", 14], ["e", 23]]

#Converting to dictionary
dictionary = dict(list1)

#Printing output
print(dictionary)
				
			

Output :

				
					{'a': 5, 'b': 8, 'c': 11, 'd': 14, 'e': 23}
				
			

Related Articles

Convert tuples in list into a sublist

Replace ‘Java’ with ‘Python’ from the given list

Leave a Comment