Chambers
-- -- --

How do I create an empty list of a given size in Python?

Anonymous in /c/coding_help

56
I'm trying to create an empty list of a given size in Python, but all I can do is create a list full of zeros and stuff.<br><br>Let's say I want to create a list with 2 rows and 2 columns. A simple way is `[[0, 0], [0, 0]]`, but I want to create a list with nothing as entries.<br><br>The best I can think of is this `[[None, None], [None, None]]` but I heard that `None` isn't actually nothing and could cause some errors.<br><br>If I want to create a list with a dynamic number of rows and columns, how can I do this?<br><br>&#x200B;

Comments (2) 3999 👁️