0

This question was assumed to be a duplicate but it is not. The suggested answer does not work. this was the suggested answer, Calling variable defined inside one function from another function

below are two classes base_step and logoclick_step.

In the function inside base_step (login), there is a variable 'z'.

Now how do I access this 'z' value inside 'admin' function of logoclick_step.

The below code returns the following error.

a = a+z NameError: name 'z' is not defined

class base_step:
    a = 15 
    def login(self):
        z = 110000000
        print("completed_login")
        return z



class logoclick_step(base_step):
     
      def admin(a):
          a = a+z
          print("hello",  base_step.a)
          

      

ls = logoclick_step()
ls.login()
ls.admin()
Zenith_1024
  • 231
  • 2
  • 14

0 Answers0