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
- Take a list of sublists as input.
- Convert the given list into a dictionary using dict() and assign it to a variable.
- 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
Python program to replace ‘Java’ with ‘Python’ from the given list.
Python program to convert the 3rd character of each word to a capital case from the given list.
Python program to remove the 2nd character of each word from a given list.
Python program to get a length of each word and add it as a dictionary from the given list.
Python program to remove duplicate dictionaries from the given list.
Python program to decode a run-length encoded given list.