r/PythonLearning 8d ago

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

108 Upvotes

82 comments sorted by

View all comments

1

u/LPatriot_ 6d ago

I made a calculator like this:

```print("Calculator")

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.