Christian

About Page: https://blog.finxter.com/about/ Testimonials: https://blog.finxter.com/what-our-users-say/

How to Create a List of Dictionaries in Python?

Problem: Say, you have a dictionary {0: ‘Alice’, 1: ‘Bob’} and you want to create a list of dictionaries with copies of the original dictionary: [{0: ‘Alice’, 1: ‘Bob’}, {0: ‘Alice’, 1: ‘Bob’}, {0: ‘Alice’, 1: ‘Bob’}]. You use list comprehension with a “throw-away” loop variable underscore _ to create a list of 3 elements. …

How to Create a List of Dictionaries in Python? Read More »