How to create a list of dictionaries in Python

1 Answer

0 votes
lst = [
	{
		'python':87,
		'java':12
	},
	{
		'c':578,
		'c++':908
	},
	{
		'php':3,
		'c#':7
	}
]

print(lst)

print(lst[0])

print(lst[0]['python'])

      

  
  
'''
run:
  
[{'python': 87, 'java': 12}, {'c': 578, 'c++': 908}, {'php': 3, 'c#': 7}]
{'python': 87, 'java': 12}
87
 
'''

 



answered Jan 13, 2021 by avibootz

Related questions

1 answer 101 views
2 answers 158 views
3 answers 179 views
1 answer 61 views
1 answer 120 views
1 answer 162 views
...