Created
April 17, 2019 18:11
-
-
Save lvreynoso/5bd2f1d5b75a2ee98fbcd20f69811beb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
High level plan: Change the calculator to a general purpose calculator that splits up input and uses python's builtin math tools. | |
Take in input | |
Split input on spaces | |
Cast first and last parts as Ints | |
If that doesn't work, return an error | |
Check for the operator in the middle piece of the input | |
If it's plus: | |
Add the first and last parts and return the answer. | |
If it's minus: | |
Subtract the first and last parts and return the answer. | |
If it's a "x": | |
Multiply the first and last parts and return the answer. | |
If it's a "/": | |
Divide the first part by the last part and return the answer. | |
If it's anything else, | |
Return an error. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment