David
David

Reputation: 1

Appending elements to a list containing empty lists

Let's say I create a list containing empty lists:

ex_list = [[], [], [], [], []]

How do I append elements to the specific empty lists contained in ex_list?

For example, I would expect that:

ex_list[0].append("a")

would return:

ex_list = [[a], [], [], [], []]

But it returns:

[['a'], ['a'], ['a'], ['a'], ['a']]

Upvotes: 0

Views: 45

Answers (0)

Related Questions