The list doesn't change because you've done nothing to change the list. Your list is Ar
-- where have you assigned a new value to anything in that list? Nowhere. All you did was to create a local variable to take on the values in Ar
, and then change the value of that variable. You never touched the original list. Instead, you have to change the list elements themselves, not their copies. Keeping close to your present code:
for i in range(len(Ar)):
Ar[i] = ArMax
Another way would be to create a new list with those items in it, and simply replace the original list all at once:
Ar = [ArMax] * len(Ar)
This looks to see how long the current list is with len(Ar)
. Then it takes a one-element list with the max value and replicates it that many times. That new list becomes the new value of Ar
.