Sitemap
Top Python Libraries

Python is widely used in fields such as data analysis, machine learning, and web development. Sharing these skills will help you advance further in your career.https://join.slack.com/t/aidisruptiont-9307882/shared_invite/zt-2vb2pzkqq-oTJmcTR_v0AWgJ31ZPfOGA

Member-only story

Common Python Bugs That Don’t Throw Errors

5 min readJun 28, 2026

--

Press enter or click to view image in full size
Photo by Emile Perron on Unsplash

Some Python bugs do not crash your program.

There is no error message. No traceback. The code runs successfully. Yet the output is wrong.

This usually happens because Python allows certain behaviors that look correct but work differently than expected.

Let’s understand these bugs one by one.

Look at the following function; at first glance, it looks completely correct. It takes an item and adds it to a list. If no list is provided, it simply uses an empty list as the default.

def add_item(item, items=[]):
items.append(item)
return items

Most beginners expect this function to create a fresh list every time it’s called. Surprisingly, that’s not what Python does.

Now look at the output:

add_item(1)   # Output: [1]
add_item(2) # Output: [1, 2]

Why is this happening?

  • The default list items=[] is evaluated only once, when the function is defined.
  • Python reuses the same list for every function call

--

--

Shwetag
Shwetag

Written by Shwetag

Engineer | Tech Enthusiast | Writing What Matters

Top Python Libraries
Top Python Libraries

Published in Top Python Libraries

Python is widely used in fields such as data analysis, machine learning, and web development. Sharing these skills will help you advance further in your career.https://join.slack.com/t/aidisruptiont-9307882/shared_invite/zt-2vb2pzkqq-oTJmcTR_v0AWgJ31ZPfOGA