Question

How to create a list initialized with N occurrences of a given value in Python?


Annonce
Ad

Answer

>>> myList=[2]*5
>>> myList
[2, 2, 2, 2, 2]


[source]
# ID Query