This is similar to the other answers since I am using a map, but what I used uses the same function that you use.
four_weeks = map(lambda i: week_array[:], range(4))
In addition, the main advantage over using _
, for example, is that it can already be used ( _
is often used by gettext), and it changes its value to the last element in the iterator. See this example:
[x for x in range(4)] assert x == 3, 'x should be equal to 3'
source share