Python’s simplicity and ease of use can mislead those who are new to the language, causing them to miss the nuance, and underestimating the power of the Python language. With that in mind, I present you a list of 5 most common mistakes while learning Python.
1. Incorrect Indentation
Many Python features rely on correct indentation. For example, when creating a function, everything inside the function must be indented under the function declaration. The same holds true for conditionals, loops and other statements. If you find your code executing an incorrect task check your indentation you’re using.
2. Wrong Operator
When you’re performing a comparison of two objects you must use the (==), and not use the assignment operator (=). The assignment operator is used to assign a value or object to a variable of your choosing.
3. The Use of Incorrect Logical Operator
Most operators don’t present problems for programmers, but logical operators do. In Python, and is used to compare objects to be True and or to find either object to be True.
Even experienced programmers suffer from spelling errors from time to time. Using the common practice of naming your variables, classes, and functions help a great deal. Naming conventions won’t always prevent from typing myNaem when you meant myName.
Python is case sensitive, so myFoo is different from MYFOO, myfoo, and MyFoo. Always check your capitalization when you’re aren’t able to access your value’s.
Familiarizing yourself with the nuances of Python, such as the moderate programming problems raised in this article, will help optimize the use of the language while avoiding errors.
Jaime Gabriel Jingco
Software Engineer/ Applied Labs Assistant Instructor