a calculator
blackjkl (35)

this calculator is not that good. It only has addition, subtraction, multiplication, division and exponents.

PLEASE COMMENT
I WANT TO HEAR WANT YOU THINK!!!!

You are viewing a single comment. View All
NotTani (46)

TL;DR: Basically, instead of going step by step, asking questions about what operator and operands to use, take this code and run it on an input. Then figure it using if statements.

Basically, here's how to use this function.
1. Take an input and store it to a variable (let's call it calcInput), wrapping it in the function from earlier. The line should look something like calcInput = breakDownExpression(input("Please enter an expression (eg. 1+1): "))
2. Then, assign the tuple elements to your first, second and user_input variables. So first = calcInput[0], user_input = calcInput[1], second = calcInput[2].
3. Just change your if statements. So instead of if user_input == '1':, use if user_input == '+':, and if user_input == '2': becomes if user_input == '-':, et cetera.
You can keep everything else. Good luck, blackjkl!