Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

100 common mistakes in Python

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]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by CyberErrorAug 6, 2018 09:24 PM 6 142 Aug 6, 2018 09:24 PM
Last Post: CyberError
[C] by BulgarianFeb 28, 2016 02:00 PM 5 204 Feb 28, 2016 02:00 PM
Last Post: Bulgarian