from typing import List
class Parent:
def __init__(self,name: str, age: int,kids: List['Child']):
self.name = name
self.age = age
self.kids = kids
def is_parent(self):
for kid in self.kids:
if kid.parent == self.name:
return True
else:
return False
class Child:
def __init__(self,name:str,age:int,parent: Parent):
self.name = name
self.age = age
self.parent = parent
parent1 = Parent("Joe",41,["Mike","Luke"])
child1 = Child("Mike",10,"Joe")
child2 = Child("Luke",9,"Joe")
print(parent1.is_parent())
In the code above Im trying to check if the parent is set as a parent in the class Child. But i keep getting AttributeError: 'str' object has no attribute 'parent' in the is_parent() function