Switching Elements in a List inside of an if statement

I am a C++ programmer and am new to python. I am trying to understand what goes on under the hood.

Let's say I have a list:

list = [1, 2, 3, 4]

Now let's say I want to switch the first and last element. I would do:

list[0], list[3] = list[3], list[0]

Now this will change the elements in the list. But why? If I do this in another scope, let's say an if statement, it does not change the elements in the list? And how do I get it to actually change the elements in the list?

So how come this doesn't work and how do I get it to work?

if 1 == 1:
    list[0], list[3] = list[3], list[0]

The list will still have the same order.