What is the difference between list and list[:] in python?

When reading, list is a reference to the original list, and list[:] shallow-copies the list.

When assigning, list (re)binds the name and list[:] slice-assigns, replacing what was previously in the list.

Also, don’t use list as a name since it shadows the built-in.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)