Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
How to call a function with one str argument and use that str as a variable to access a variable present inside a class.
Please check the attached code https://code.sololearn.com/cQPRaiR41s3B/?ref=app
1 Resposta
0
You can assign it to the class variable as shown below. You can interact with the passed variable and the object variable by using āselfā or not using āselfā.
class MyClass:
a = 0
b = 5
def classfun(self, a):
self.a = a
print (self.b * a)
obj = MyClass()
obj.classfun(10)