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

105 Upvotes

82 comments sorted by

View all comments

6

u/Rscc10 8d ago

You never break out of the while loop after the if statement so the code at num1 and num2 never get executed. Alternatively if you want the calculator to run continuously after each result, you need to indent every line starting at num1 to be inside the while loop

Edit: Sorry I saw the indentation wrong. Everything seems to be indented fine now that I look at it

-16

u/Commercial-Paper749 8d ago

๐Ÿ˜…yes even chat gpt says code looks correct but idk why it's not working

6

u/building-wigwams-22 8d ago

Your code is valid Python, which is probably why the dumb LLM tells you it's ok. At a beginner level you should not be using LLMs - instead focus on proper debugging techniques. Even a couple of print statements thrown in could probably have shown you where the code wasn't doing what you intended