How do I report a modified list without modifying the list

I was creating a block called

(all but last of $list ::list)

with the definition being


but I ran to a problem when I was modifying a global variable with the value being a list and when I tried that block with the input being the global variable it modified it. Can someone help me?

You can create a deep copy of the list

Also untitled script pic (14) makes a shallow (one level deep) copy of the list.

Thanks for the help!

Here is a tutorial that goes into detail about how this works: Common pitfalls when working with lists (and how to avoid them)

helpful FAQ post you should read: I copied a list to another variable, and then when I change the copy, it changes the original too! - #13

although I think sometimes that is slower than the alternative.

You may leave out the outermost reverse if the order of the elements doesn’t matter.

I haven't actually tested the speeds of these options, but just throwing this out there.

(item (numbers from (1) to (([length V] of (list)) - (1))) of (list)) // works for length > 1