I Have that code:
class Welcome(object):
MyHouse='Earth'
def say(self, what):
print(what, self.MyHouse)
welcome = Welcome()
Living = ['World', 'Planet', welcome.MyHouse]
MyChoice = list(map(lambda choice : setattr(welcome, 'MyHouse', choice), Living))
print(''.join(str(MyChoice) for MyChoice in MyChoice))
getattr(welcome, 'say')('Hello')
with this code , I want to use setattr() to change the MyHouse variable according to the strings contained in the Living list, but when I see the results I only get None objects ?, why this and how can I fix it, it would be because setattr does not give output ?.
print(MyChoice)
Output: [None, None, None]
setattrwould return? - chepner