0

How to assign a variable returned from a local function to a global variable in python

I want to assign rents to be an instance of the class Parents but I'm unsure how to assign the variables returned from the function Get_Parents. Any help would be much appreciated :) https://code.sololearn.com/cOZsIfm0A9l0/?ref=app

14th Jul 2017, 9:51 AM
StealthyTaco
StealthyTaco - avatar
1 Odpowiedź
+ 6
class Parents(): def __init__(self, mom, dad): self.mom = mom self.dad = dad def getParents(self, parent): return self.mom if parent == 'mom' else self.dad rents = Parents(input('Moms name: '), input('Dads name: ')) print(rents.getParents('mom'))
14th Jul 2017, 11:35 AM
Maya
Maya - avatar