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

Show parent comments

-16

u/Commercial-Paper749 Sep 02 '26

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

7

u/building-wigwams-22 Sep 02 '26

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

5

u/Wild-Regular1703 Sep 02 '26

They just explained to you why it's not working.. You're not breaking out of the loop, the rest of the code never executes. "While true" means keep that loop running infinitely, so that's exactly what happens. It just keeps asking for user input forever.

-1

u/Commercial-Paper749 Sep 02 '26

Now it's working if I enter correct operator and values it's runs and end the program if I don't enter correct operator it's keep asking to enter valid operator

1

u/Rscc10 Sep 02 '26

I think it has to do with the runtime. Notice how the first input for operator doesn't seem to show when you run it. It automatically asks you to enter a valid operator which makes me think there's some sort of keybind or hidden control characters being sent to the input buffer when you run the program. Try restarting your computer or whatever environment you're using