A beginner Python mistake that taught me to stop blaming the code and start reading the error
When I started learning Python, I thought small programs would be easy.
I decided to make a simple program that checks a student's marks.
My first attempt...Read More
marks = input("Enter your marks: ")
if marks >= 50:
print("You passed!")
else:
print("You failed!")
It looked completely normal to me.
I entered:
Enter your marks: 70
And then Python complained. 😅
At first, I was confused.
"But 70 is greater than 50. Why isn't this working?"
Then I looked at my code again.
The problem was this:
marks = input()
The mistake
When we use input(), Python receives the...Read More
So even though I typed:
70
Python was treating it like:
"70"
I was trying to compare text with a number:
"70" >= 50
That's where my mistake was.
The fix
I needed to convert the input into an integer:
marks = int(input("Enter your marks: "))
if marks >= 50:
print("You passed!")
else:
print("You failed!")
Now when I enter:
70
Python understands it as the number:
70
And the program works.
What did I actually learn?
The important lesson wasn't just "use int()."
I learned something more important:
Don't immediately assume...Read More
When a program gives an error:
Read the error.
Look at the line causing the problem.
Check what type of data you're working with.
Make one change.
Run the program again.
As a beginner, I sometimes want to fix everything immediately.
But I'm learning that debugging is a process.
You don't need to understand everything at once.
Sometimes one small error can teach you more than a...Read More
My Python learning lesson
I'm still learning Python step by step.
I don't want to memorize code and simply copy someone else's solution.
I want to understand why my code works—and why it doesn't work when I...Read More
And honestly, these small errors are becoming part of my learning journey.
What about you?
What was one small Python mistake that taught...Read More
I'd love to hear from other beginners. 👇
Top comments (1)
One thing I'm realizing during my Python journey is that errors aren't always failures. Sometimes they're actually giving us a clue about what we misunderstood.