So I'm currently writing a program where I need a function that I run recursively to return a class object. See code below:
def checkEqual (p1:Player, p2:Player, playerListNum):
if p1 == p2 and playerListNum >= 2:
np2 = r.choice(verySpecificListVariable)
print(type(np2))
checkEqual(p1, np2, playerListNum)
else:
print(type(p2))
return p2
Then later in the code I run:
p1 = r.choice(verySpecificListVariable)
p2 = checkEqual(p1, r.choice(verySpecificListVariable), len(verySpecificListVariable))
print(type(p2))
verySpecificListariable being a list of class objects.
So the first two prints give me what i'm looking for: a class object. However the last one throws a NoneType. From this I deduced that for some odd reason, the function was turning the class object into a NoneType as soon as it returns it into the p2 variable.
(at p2 = checkEqual(p1, r.choice(verySpecificListVariable), len(verySpecificListVariable))
)
I need to reference p2 later in the code as a class object, but obviously the NoneType does NOT like that. Thank you for your time, and any assistance is greatly appreciated.