Common Python Mistakes New Coders Repeat and How to Fix Them
I have watched a lot of beginners work through their first few weeks of Python, and the mistakes rarely surprise me anymore. They are not random.

I have watched a lot of beginners work through their first few weeks of Python, and the mistakes rarely surprise me anymore. They are not random. A small set of misunderstandings about how the language actually works shows up again and again, in almost the same order, regardless of the person's background. None of them mean someone is bad at this. They mean Python hides a few of its rules well enough that you only learn them by hitting the wall first.
Confusing print with return
The single most common mistake I see is a function that prints a result instead of returning it, then gets used as if it had returned something. The function runs, a number appears on the screen, and the learner assumes the job is done. Then they try to use that value in another calculation and get an error about adding an integer to nothing, because a function with no return statement actually hands back a special value that means nothing at all, not the number that was printed. Printing shows a human what happened. Returning hands a value back to the rest of the program so it can keep working with it. These are two different jobs, and a function often needs to do the second one even when it looks, on screen, like printing was enough.
Mutating a list while looping over it
Removing items from a list while you are looping through that same list is one of those mistakes that produces baffling, inconsistent results rather than a clean error. Some items get skipped entirely, seemingly at random, because the loop is tracking position by index, and removing an item shifts every item after it one position earlier, which the loop does not know happened. The fix is usually to loop over a copy of the list while modifying the original, or to build a brand new list of the items you want to keep instead of deleting from the one you are iterating. This mistake connects directly to the loop mechanics covered in Python loops explained with things you already do, since understanding what a loop is actually tracking as it goes is exactly what prevents this bug.
Comparing floating point numbers with equals
New coders are often shocked the first time a line that should obviously be true, like checking whether zero point one plus zero point two equals zero point three, comes back false. This is not a bug in Python. Floating point numbers are stored in a binary format that cannot represent most decimal fractions exactly, so tiny rounding differences accumulate during arithmetic. The practical fix is to never compare floating point numbers for exact equality. Instead, check whether the difference between two numbers is smaller than a tiny tolerance value, which is how real code handles this everywhere, from games to financial calculations.
Using a mutable default argument
This one catches people who are past the total beginner stage and starting to write their own functions with default arguments. Setting a default value of an empty list for a function parameter seems harmless, but that empty list is created exactly once, when the function is defined, and every call that uses the default shares the same list object. Append something in one call, and it mysteriously shows up as already there the next time the function runs with no arguments given. The standard fix is to default the parameter to a value representing nothing, and build a fresh empty list inside the function body on each call instead.
Giving up the instant an error message appears
This is less about syntax and more about habit, but it causes more stuck sessions than any single rule above. A lot of beginners read the first line of a long error message, feel overwhelmed, and stop reading. The most useful information in a Python error is almost always at the very bottom, in the final line, which names the actual exception and the specific problem. The lines above it are a trail showing which function called which other function to get there, useful for context but not where the answer usually sits. Training yourself to read error messages from the bottom up, rather than giving up at the top, fixes more bugs than almost any other single habit. This is the same instinct I write about in how to get unstuck on a practice problem without peeking, where learning to read your own error output carefully is often faster than searching for the answer online.
Writing one giant function that does everything
Beginners often write their first working program as a single long function, because breaking it apart feels like an extra step when the thing already runs. The trouble shows up later, when something breaks and there is no way to test one piece without running the whole program. A function that does five different jobs is five times harder to debug than five small functions that each do one job, since you can test each piece on its own and know exactly where the problem lives. I go into this specific habit more in why your first functions should do only one thing, which is worth reading once the "everything in one block" pattern starts to feel cramped.
Not understanding what an indentation error is actually telling you
Python uses indentation to show which lines belong inside a loop, function or conditional, rather than using brackets like some other languages. An indentation error almost always means a mix of tabs and spaces, or a line that is indented one level too many or too few relative to the block it is supposed to belong to. Most code editors can be set to show whitespace characters and to automatically convert tabs to spaces, which eliminates this entire category of mistake before it happens, and it is worth turning that setting on in week one rather than fighting it for months.
A short list to check when something breaks
- Does the function actually return the value, or just print it.
- Are you removing items from a list while looping over that same list.
- Are you comparing floating point numbers with exact equality.
- Does a function use a mutable default argument like an empty list.
- Have you read the full error message, especially the bottom line.
- Could this function be split into smaller pieces that are each easier to test.
These mistakes are not a sign you are behind
Every one of these trips up nearly everyone who learns Python, often more than once, because the language does not make any of these rules obvious until you have personally been bitten by them. Recognising the pattern the second time is what actually counts as progress, more than never making the mistake in the first place. More practice and troubleshooting like this lives in our Python and Practice section.
More in Python and Practice
Python and Practice
How to Practice Python With Small Daily Exercises
People learn to code the way they learn an instrument, through regular small practice rather than occasional marathon sessions.
Python and Practice
Why Your First Functions Should Do Only One Thing
A beginner's first few functions almost always try to do genuinely too much at once, calculate a value, print a result, and...
Python and Practice
How to Get Unstuck on a Practice Problem Without Peeking
Every programmer gets stuck. Beginners get stuck on loops and syntax errors; experienced developers get stuck on tricky bugs...