I have three lists. Two are returned from functions. The other list, list_c, is being created in the program out of some hardcoded options and some variables, and the contents of these lists. This list is a list of arguments to be passed to another program, so the order is important. I need each item in list_a and list_b to be in the middle of list_c in a certain position. Both list_a and list_b are variable in length.
list_a = some_function()
list_b = some_other_function()
list_c = ['some', 'stuff', list_a, 'more', list_b, variables]
Basically, I want something like the above, except giving a flat list instead of a nested list.
I could do:
list_c = ['some', 'stuff']
list_c.extend(list_a)
list_c.append('more')
list_c.extend(list_b)
list_c.append(variables)
but that looks a bit clunky and I was curious if there was a more elegant way to do it.
How about this? You can append/concatenate lists with
+['some', 'stuff'] + some_function() + ['more'] + some_other_function() + [variables]