why does variable assignment in lists not work?

Both these methods do an in-place modification, i.e.:

b = a.reverse()
f = e.append(4)

They modify the original object and do not create a new one. Hence, you see None when you try and print these.

As per @juanpa.arrivillaga:

Note: The fact that these methods return None is a convention.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top