Help with Python classes

I want to call a method of class A, from class B; but I get an error which I do ot understand.
Can anyone help me resolve my issue?
Here’s my code and error:

class Environment:
def init(self,state):
self.loc1_ = ‘A’
self.loc2_ = ‘B’
self.state_ = state

    def setloc1_state(self,state): #state='D'
	self.state_[0] = state

class Agent:
def init(self,percept:list,location:‘str’,action:‘str’=‘N’,goal:list=[‘C’,‘C’]):
self.percept_ = percept
self.cost_ = 0
self.location_ = location
self.action_ = action
self.goal_ = goal

   def clean(self):
	place = self.getlocation()
	if place == 'A':
		Environment.setloc1_state(self,'C')
	if place == 'B':
		Environment.setloc2_state(self,'C')

def main():
init_state = [‘D’,‘D’]

house = Environment(init_state)

vacuum = Agent(percept=house.getstate(),location='A')

while house.getstate() != ['C','C']:
	vacuum.execute_action(house.getstate())
print(house.getstate())

main()

I get this error:
AttributeError: ‘Agent’ object has no attribute ‘state_’; related to this line of the clean() function:
“Environment.setloc1_state(self,‘C’)”

I read several tutorials which explains this concept ofcalling class members from another class, and those examples worked. So, I’m not sure why this code snippet does not distinguish between the “self” variabble linked to the 2 different classes.

Please educate me?

I don’t know what Digi product you are working with, but the product may not support the class function or it could be that the version of Python supported by the device uses a different call for Class.

Hi this is Palak
I also worked with Python. And I also faced these kind of problem while I was developing Snake game using Python. In my recent search I have seen this post(https://www.techgeekbuzz.com/blog/python-attributeerror-str-object-has-no-attribute-append-solution/) over the internet it can helps you.

Thanks