It doesn't allow me to use a variable with an attribute of the class. Not sure how to manage this. I need the answer to come out as 7. But I need to be able to use the variable for it. gives me the error,
Traceback (most recent call last): File "c:/Data/First Game (Python)/rough.py", line 32, in a.add_2(5) AttributeError: 'str' object has no attribute 'x'
I think it is not able to recognize that by a I meant to mention Me1.
class Test():
def add_2(self, y):
print(y + 2)
Me1 = Test()
for i in range (1):
a = "Me" + str(i+1)
print (a)
a.add_2(5)