0

Strange thing:

>>> a = [1, 2, 3, 4, 5, 6, 7]

>>> b = a[1:]

>>> b

[2, 3, 4, 5, 6, 7]

>>> b.append(a[0])

>>> b

[2, 3, 4, 5, 6, 7, 1]

It works fine - b is the circular shift of elements from a array.

But when I'm trying to do the same in one line:

>>> b = a[1:].append(a[0])

>>> b

>>> # b is none

Why?!?!?!

a[1:] - is a new list and it has the append method - everything is fine but why the results of two line and one line realizations are different?

Community
  • 1
  • 1

0 Answers0