Given a list of values:
data = [100, 80, 200, 20, 300, 100, 400, 40, 500, 120, 600, 60]
I want to extract the first two and the last two values, and create a new list. Unfortunately, the way I’m doing things right now, I get a list which contains two lists:
bla = [data[0:2], data[-2:]]
print bla
[[100, 80], [600, 60]]
Instead I would like to get this:
[100, 80, 600, 60]
Is there an easy way of doing this?
(this question is somewhat related to this question, but I still think it’s different enough)
Use list concatenation with
+: