I'm trying to figure out how to properly append to the friends list initialised in the constructor and have tried a few different angles. I know that self.friends.append(SocialNetworkUser)
is the issue, but not sure how to properly modify.
class SocialNetworkUser:
potentialFriends = []
def __init__(self, name, friends=[]):
self.name = name
def befriend(self, SocialNetworkUser):
self.potentialFriends.append(SocialNetworkUser)
if self in SocialNetworkUser.potentialFriends:
self.friends.append(SocialNetworkUser)