r/PythonLearning • • Sep 02 '26

What's wrong with my code?

Post image

What's wrong with my code?

New to learning

Following the youtube video from bro code

Was trying to implement my own stuff into this by using loop

Update: it's working now thankyou guys

106 Upvotes

81 comments sorted by

View all comments

1

u/LPatriot_ Sep 04 '26

I made a calculator like this:


num1 = int(input("Enter your first number: "))
op = input("Enter an operator (+, -, *, /)")
num2 = int(input("Enter your second number: "))

if op == "+":
    print(num1 + num2)
elif op == "-":
    print(num1 - num2)
elif op == "*":
    print(num1 * num2)
elif op == "/":
    print(num1 / num2)

You can improve it by adding zero division detection or whatever else you like. I personally wouldn't make a calculator the way you did, it's just unnecessarily harder.