Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- num1 = float(input("Please enter the first number: "))
- checkError = True
- while checkError:
- operation = int(input("Do you want to: \n 1) Add; 2) Subtract; 3) Multiply; 4) Divide: "))
- arr = [1,2,3,4]
- if operation in arr:
- checkError = False
- print("Invalid input!! Please try again")
- num2 = float(input("Please enter the final number: "))
- if operation == 1:
- result = num1 + num2
- elif operation == 2:
- result = num1 - num2
- elif operation == 3:
- result = num1 * num2
- elif operation == 4:
- result = num1 / num2
- print(f'The result is {result}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement