I have to make class objects with dictionaries inside. I can't figure out how to change values when making them. I can change them after, but same code doesn't work inside making line.
There are some attempts (#tells error from code below, i did't change anything other than machine1 making code):
#on this i get error: keyword cant be expression
class One():
def __init__(self, problem):
self.problem = {
"year": 0,
"model": 0,
"stupidity": 0
}
machine1 = One(problem[year]=1)
#TypeError: __init__() takes 2 positional arguments but 4 were given
class One():
def __init__(self, problem):
self.problem = {
"year": 0,
"model": 0,
"stupidy": 0
}
machine1 = One(1,1,1)
#does't change anything
class One():
def __init__(self, problem):
self.problem = {
"year": 0,
"model": 0,
"stupidy": 0
}
machine1 = One(1)
print(machine1.problem["year"])
#I can change it later with this
machine1.problem["year"] = 1