#!/usr/bin/env python3
class calculator:
    def oldFunk(x, y):
        i = input(('a = add \ns = subtract \nm = multiply \nd = divide \n: '))
        if i == 'a':
            print(x, '+', y, '=', calculator.addi(x, y))
            while True:
                z = input('would you like to continue? y or n : ')
                if z == 'y':
                    calculator.oldFunk(x, y)
                elif z == 'n':
                    exit()
                else:
                    print('invalid input. These are your options :')
                    calculator.oldFunk(x, y)
        elif i == 's':
            print(x, '-', y, '=', calculator.subt(x, y))
            while True:
                z = input('would you like to continue using the same numbers? y or n : ')
                if z == 'y':
                    calculator.oldFunk(x, y)
                elif z == 'n':
                    q = input('would you like to quit? y or n')
                    if q == 'n':
                       calculator.newFunk()
                    else:
                       exit()
                else:
                    print('invalid input. These are your options :')
                    calculator.oldFunk(x, y)
        elif i == 'm':
            while True:
                print(x, '*', y, '=', calculator.mult(x, y))
                z = input('would you like to continue? y or n : ')
                if z == 'y':
                    calculator.oldFunk(x, y)
                elif z == 'n':
                    exit()
                else:
                    print('invalid input. These are your options :')
                    calculator.oldFunk(x, y)
        elif i == 'd':
            print(x, '/', y, '=', calculator.divi(x, y))
            while True:
                z = input('would you like to continue? y or n : ')
                if z == 'y':
                    calculator.oldFunk(x, y)
                elif z == 'n':
                    exit()
                else:
                    print('invalid input. These are your options :')
                    calculator.oldFunk(x, y)
    def newFunk():
        x = int(input('Select the first number : '))
        y = int(input('select your second number : '))
        print("Choose you're function")
        i = input("a = add \ns = subtract \nm = multiply \nd = divide \n: ")
        if i == 'a':
            while True:
                print(x, '+', y, '=', calculator.addi(x, y))
                n = input('Use new numbers? y or n : ')
                if n == 'y':
                    calculator.newFunk()
                elif n == 'n':
                    calculator.oldFunk(x, y)
                else:
                    print('invalid input, try again')
                    calculator.oldFunk(x, y)
        elif i == 's':
            while True:
                print(x, '-', y, '=', calculator.subt(x, y))
                print('Use new numbers? y or n : ')
                n = input('')
                if n == 'y':
                    calculator.newFunk()
                elif n == 'n':
                    calculator.oldFunk(x, y)
                else:
                    print('invalid input, try again')
                    calculator.oldFunk(x, y)
        elif i == 'm':
            while True:
                print(x, '*', y, '=', calculator.mult(x, y))
                print('Use new numbers? y or n : ')
                n = input('')
                if n == 'y':
                    calculator.newFunk()
                elif n == 'n':
                    calculator.oldFunk(x, y)
                else:
                    print('invalid input, try again')
                    calculator.oldFunk(x, y)
        elif i == 'd':
            while True:
                print(x, '/', y, '=', calculator.divi(x, y))
                print('Use new numbers? y or n : ')
                n = input('')
                if n == 'y':
                    calculator.newFunk()
                elif n == 'n':
                    calculator.oldFunk(x, y)
                else:
                    print('invalid input, try again')
                    calculator.oldFunk(x, y)
        else:
            print('invalid input')
            calculator.oldFunk(x, y)
    def addi(x, y):
        return(x + y)
    def subt(x, y):
        return(x - y)
    def mult(x, y):
        return(x * y)
    def divi(x, y):
        return(x / y)
calculator.newFunk()⏎ 
