Logo

Best

Popular

It's probably neater to do new_list = [list(range(10)) for _ in range(10)] although mostly opinion based – Markus Meskanen Jun 12 '17 at 15:08 Thanks @MarkusMeskanen , my idea was to make it simpler for OP and do the exact same thing that they are trying to do but with list comprehensions :) – ettanany Jun 12 '17 at 15:18 I have a list of integers that has a certain capacity that I would like to automatically fill when declared. List<int> x = new List<int>(10); Is there an easier way to fill this list with 10 ints that have the default value for an int rather than looping through and adding the items?