class Questionare:
def ask_age(self):
try:
age = int(input('Type your age after the arrow -> '))
self.age = age
print(['inside'], self.age)
return self.age
except ValueError:
print('Only use numbers to inform your age!')
self.ask_age()
def __init__(self):
self.age = self.ask_age()
print(['__init__'], self.age)
if __name__ == '__main__':
user_data = Questionare()
print(['outside'], user_data.age)
Why is it habing such behavior? the result inside is "ok", but the output returns None. What goes on?
Type your age after the arrow -> a
Only use numbers to inform your age!
Type your age after the arrow -> 12
['inside'] 12
['__init__'] None
['outside'] None