From d62cab3420c36b0e0985d7b75a0f10a331dfb687 Mon Sep 17 00:00:00 2001 From: Braeden McHugh Date: Wed, 12 Feb 2025 06:37:42 -0500 Subject: [PATCH] Adding subtraction --- hw01/main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw01/main.py b/hw01/main.py index f931dcc..020d1d7 100644 --- a/hw01/main.py +++ b/hw01/main.py @@ -1,11 +1,13 @@ def add(x,y): return x+y +def sub(x,y): + return x-y def calc(): while(True): - operation = input("Enter operation from [+]: ") - if operation == "+": + operation = input("Enter operation from [+,-]: ") + if operation =="+" or operation == "-": break print("Enter valid operation") @@ -15,6 +17,9 @@ def calc(): if operation == "+": print(add(x,y)) + if operation == "-": + print(sub(x,y)) + if __name__ == "__main__": calc() \ No newline at end of file