Source From Here
Question
Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]. Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?
How-To
Below sample code use Python built-in range to create list:
Question
Say we have a list of numbers from zero to 1000. Is there a pythonic/efficient way to produce a list of the first and every subsequent 10th item? ie. [0, 10, 20, 30 ...]. Yes I can do this using a for loop but I'm wondering if there is a neater way to do this, perhaps even in one line?
How-To
Below sample code use Python built-in range to create list:
沒有留言:
張貼留言