So I was programming something in python that had to do with assigning a class variable to an instance variable, and then changing the instance variable inside the init method. I simplified the code a bit, when I run it the class variable gets changed as well:
class Map():
    map = [1,2,3]
    def __init__(self): 
        self.map = Map.map
        for i in range(len(self.map)):
            self.map[i] = self.map[i] * 2
        print("self.map =", self.map)
        print("Map.map =", Map.map)
new_map = Map()     
When I run it, I get the following output:
self.map = [1, 4, 9]
Map.map = [1, 4, 9]
Basically I was wondering why Map.map gets changed even though I only changed self.map?
 
     
     
     
     
    