def promptCustom(self): print("Which operation do you want?") print(" 1. Multiplication") print(" 2. Addition") print(" 3. Subtraction") print(" 4. Division") text = input("Operation: ") op_choice = int(text) op_choices = { 1: Operation.multiplication(), 2: Operation.addition(), 3: Operation.substraction(), 4: Operation.division() } OPERATION = op_choices.get(op_choice, Operation.multiplication()) # text = input("Left hand side start: ") LHS_START = int(text) text = input("Left hand side end: ") LHS_END = int(text) text = input("Right hand side end: ") RHS_START = int(text) text = input("Right hand side end: ") RHS_END = int(text) text = input("Number of questions: ") NUMBER_OF_QUESTIONS = int(text) result = UserOptions() result.operation = OPERATION result.lhs_min = LHS_START result.lhs_max = LHS_END result.rhs_min = RHS_START result.rhs_max = RHS_END result.number_of_questions = NUMBER_OF_QUESTIONS return result
except ValueError: print("not a number! please try again") continue while True: second_number = input("input second number: ") try: second_number = int(second_number) except ValueError: print("not a number! please try again") continue if second_number == 0 and operation == '/': print("thats illegal..") else: break if operation == '+': Operation.addition(first_number, second_number) elif operation == '-': Operation.subraction(first_number, second_number) elif operation == '/': Operation.division(first_number, second_number) elif operation == '*': Operation.multiplication(first_number, second_number) else: print("surprise! Theres a flaw in the logic -_-")