A
A
Alexander Matvienko2021-12-24 19:12:29
Python
Alexander Matvienko, 2021-12-24 19:12:29

How to complete the list?

Let's say I have a list: How can I put new data to come out: And how can I make it so that if in 2: abc, def, 123. Then in 1 add: xyz, "", ""
data = {"1": ["xyz", ""]}

{"1": ["xyz", ""], "2": ["abc", "def"]}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2021-12-24
@d1mpi

so list or dictionary?
your example is like this:
data["2"] = ["abc", "def"]

A
Alexander Matvienko, 2021-12-24
@d1mpi

The second question was solved with this solution:

long = 0
    for val in data.values():
        if long < len(val):
            long = len(val)

    for val in data.values():
        add_long = long - len(val)
        for row in range(add_long):
            val.append('')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question