system
                
              
                
              
                  
                  
              1
              
             
            
              
 | 
 | 
 | 
  | 
Attention | 
Topic was automatically imported from the old Question2Answer platform. | 
  | 
Asked By | 
scooty | 
 var P1 = 5
var P2 = 10
var P3 = 15
var Points
Points = [P1, P2, P3]
for i in Points:
       i = 0
print(Points[0]
That’s my  code
It prints 5. Why can’t I change a value in a table?
             
            
              
              
              
            
           
          
            
              
                system
                
              
              
                  
                  
              2
              
             
            
              
 | 
 | 
 | 
  | 
Reply From: | 
spaceyjase | 
 The for loop i is a copy of each element in the array, the same way this doesn’t change P1:
var P1 = 5
var P2 = P1
P2 = 0
print(P1) # 5
If you want to change an array element, you need to loop using a index:
for i in Points.size():
    Points[i] = 0
print(Points[0]) # zero