Hack Forums
[Python] 100 common mistakes in Python - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] 100 common mistakes in Python (/showthread.php?tid=6291285)



100 common mistakes in Python - Hackers - Feb 3, 2025

I found this site which seems to be a good resource for people just starting to learn Python. However, there might be some reminders for advanced coders too! Take a look

100 common Python mistakes:
https://thepythonbook.com/en/common-python-mistakes

Example:
Code
Confusing append and extend

❌ Do not confuse append with extend. The following code fails because extend is intended for use with lists.
x = [1, 2, 3]
x.extend(4)
print(x) # TypeError

✅ If you want to add a single element, use append.
x = [1, 2, 3]
x.append(4)
print(x) # [1, 2, 3, 4]