Advertisement
Guest User

koodi

a guest
Jan 29th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. def add(x, y):
  2. return x + y
  3. def subtract(x, y):
  4. return x - y
  5. mylist = []
  6. while True:
  7. print("Do you want to add or subtract? If you want to exit type exit.")
  8. choice = input("Enter choice(add/subtract): ")
  9.  
  10. if choice == 'exit':
  11. break
  12.  
  13. num1 = float(input("Enter first value: "))
  14. num2 = float(input("Enter second value: "))
  15.  
  16. if choice == 'add':
  17. print(add(num1,num2))
  18. mylist.append("")
  19.  
  20. elif choice == 'subtract':
  21. print(subtract(num1,num2))
  22. mylist.append("")
  23.  
  24. else:
  25. print("Please only select add or subtract")
  26.  
  27. continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement