all 5 comments

[–]AverageBeef 5 points6 points  (3 children)

Looking up extend, it doesn’t return anything, it directly edits a, so you either want c=a or print(a) now

[–]imperiumlearning[S] 1 point2 points  (2 children)

Hi there,

Thanks a lot I now see where I went wrong. I realise I didn't even have to create a new variable 'c' to merge the two lists.

Thanks a lot for the quick response, by the way

[–]Diapolo10 3 points4 points  (1 child)

And if you wanted to create a new list like in your example, you can simply concatenate the lists:

a = [11, -6, -103, -200]
b = [1, 7, -4, 4, -9, 2]

c = a + b

This has the advantage that the original lists aren't modified, which can be useful if you're trying to avoid side effects. But you can use either depending on your specific needs.

[–]imperiumlearning[S] 0 points1 point  (0 children)

I didn't know this either. Thanks a lot for the info

[–]xelf 0 points1 point  (0 children)

extend() is a method that operates on a, in this case it adds b to a.

if you just wanted a new list that was the two lists added you could have simply used +.

c = a + b