This is the code for a calculator function. It takes the first and second number, combines them and asks for an input whether the calculation was correct. If the input is "Yes", a statement is printed. If the input is "No", a different statement is printed.
def calculator(number1,number2): answer = ['Yes', 'yes'] print("The first number is %d." % number1, "The second number is %d." % number2) print("The sum is %d." % (number1 + number2)) if input("Am I right? \nANSWER : ") in answer: print("Knew it!") else: print("Oh, well. Blame my programmer!")
Is there anything I can do to optimize the code and make it shorter and / or simpler?