I'm not sure if it works with that, but arrays works differently when you use =, for example Arr1 = Arr2 will not copy the values but link those two arrays together, so if one change, the other change as well, which can be very confusing. You can use Arr1 = copy Arr2 to make those arrays unique, and maybe you can do the…