X
X
xomiles2021-12-07 22:14:09
Python
xomiles, 2021-12-07 22:14:09

How to add to dictionary?

I have an empty dictionary sl = {} , I need to add data to it to get it like this [{"id": 1, "name": "name"}, {"id": 2, "name": "second name"}, etc.] How to do this, I can’t figure out how, I searched on the Internet, but didn’t find what I need, or I didn’t search well, but oh well, please help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-12-07
@fox_12

I have an empty dictionary sl = {}

I need to add data to it so that it looks like this [{"id": 1, "name": "name"}, {"id": 2, "name": "second name"}, etc.]

Let's start with data structures. In the first case - you have a dictionary, in the second case - a list. The list may contain a list of dictionaries. Start from this.
I searched on the Internet, but did not find what I need, or I searched badly

Come on ... And open any textbook op Python to read - didn't you guess?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question