I am creating an empty dictionary inside a class and then I am trying to give the variables inside the dictionary some value. As shown in the code below. In the end, I am trying to print the dictionary values in the console but I receiving errors
In the editor:
import numpy as np
class A:
def __init__(self, variables = {}):
self.variables = {}
if ("leng") in variables:
self.variables["leng"] = variables["leng"]
else:
self.variables["leng"] = np.array([10,])
if ("width") in variables:
self.variables["width"]= variables["width"]
else:
self.variables["width"] = np.array([10,])
In the Console:
variables.items()
>>>"leng" : 10
>>>"width" : 10