Answer the question
In order to leave comments, you need to log in
How to create a list like [0,1...n]?
The bottom line is that I have a function that needs to be given some value as input. Inside this function, I have a list and, depending on the input value, it should change the length. Those. initially I have a list [0,1]
I give as input 6 receive a list [0,1,0,0,0,0]
Answer the question
In order to leave comments, you need to log in
Such a list can be obtained using list comprehensionsyour_list = [i for i in range(n)]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question