Mar-30-2019, 05:43 PM
I wrote this program and it works like I want it too but the __init__ method doesn't do anything. I have read and watched tutorials but I can't figure out how to apply the __init__ method with the input() function. How do I make __init__() more than just decoration and still get the same results?

class Person(): def __init__(self, name, age): self.name = name self.age = age def get_name(): """Get the user's name.""" enter_name = input('Enter your name. ') return enter_name def get_age(): """Get the user's age.""" enter_age = input('Enter your age. ') return enter_age def main(): name = Person.get_name() age = Person.get_age() print(f'My name is {name}. I am {age}.') if __name__ == "__main__": main()
Output:Enter your name. micah
Enter your age. 37
My name is micah. I am 37.