Search code examples
pythonarraysrangeconcatenation

use 'range' inside of an array multiple times in python


I looked and couldn't find a similar question probably because I'm a python noob and don't know the proper language to search.

is there a way to do this...

frame_inds = [0,  list(range(200, 2000, 100)), 3999]

the output I get is this

[0, [200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900], 3999]

but I want this

[0, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 3999]

so that it is all in one array?

in matlab you can do this var1 = [1, 2, 3:10:100, 400]


Solution

  • frame_inds = [0,  *range(200, 2000, 100), 3999]
    

    By using the * operator you can unpack all its items and they become items in the main list.