# Repeat Loop Variable Bug

Browser: Chrome
Example Project: See below
Steps: See below
Snap Does: Change an input variable that is never edited
Snap Should: Leave the variable untouched

Hi there! Came across this issue while making a graphing calculator. I apologize I wasn't able to narrow down the source of the issue, but the only way I could reproduce it was in the form shown (unfortunately the way I need it to work). Essentially, using the process below, the variable "a" (an input of the block) never has a function that should alter its value. The code only alters "b", which in each loop is copied from "a", but yet somehow "a" is changed in the end.

Hopefully this can be fixed soon. Thanks!

When you set a variable to a list ("set b to a" in your code), this is not a deep copy, but variables b and a point to the same list. So when replacing an item in b, also a will see this.

To copy a list, use the "keep items" block for functional programming with lists: "keep items <true> from a" creates a copy of the list pointed to by a, which can be assigned to b:

set b to (keep items <true> from a)

Hi there!

Thanks for the quick response. That's unfortunate and a little confusing to use... I hadn't heard of the keep items, but seems straight forward. Thanks for your help.