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
1 ответ
+ 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'))