0

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

26th Apr 2021, 6:16 PM
Abhishek Kumar
Abhishek Kumar - avatar
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)
26th Apr 2021, 9:11 PM
Jerry Hobby
Jerry Hobby - avatar