Preventing Bugs
Learn how we can prevent different types of bugs during programming in Python.
We'll cover the following
- Bug 1: Mixing tabs with spaces in indentation
- Bug 2: Missing : in an if, loop, function, or class
- Bug 3: Using ++ or --
- Bug 4: No static types for variables
- Bug 5: Deleting an item
- Bug 6: Improper interpretation of the range() function
- Bug 7: Using = in place of ==
- Bug 8: Objects of built-in and other types
- Bug 9: Using improper case in logical values
- Bug 10: Improper order of function calls
- Bug 11: Improperly mutable default value
- Bug 12: Common exceptions
How can we prevent bugs in a Python program? It seems there’s no certain way to do that. So we decided to make a list of common programming mistakes.
Bug 1: Mixing tabs with spaces in indentation
Consider the code snippet shown below:
Get hands-on with 1200+ tech skills courses.