Python Exception Class

Ten common mistakes which must be avoid by for Python beginners

Python is a relatively easy language to get started with, and there is plenty of room for beginners to find programming skills. However, like any programming language, it can be prone to common mistakes that prevent code execution.

 

These are 10 Common Mistakes In Python that most beginners make. Identifying these errors can reduce future headaches.

 

  1. Version: To add to the confusion that most beginners already face when they start programming, Python has two live versions of the languages ​​available for download. Version 3.6.x is the latest version, and it is recommended that you start. However, the 2.7.x code does not always work with the 3.6.x code. The reverse is also true.
  2. Internet-Every programmer has the internet, and at some point, he will access the internet, copy the code, and insert it into his own routine. It's okay to use someone else's code, but before you can blindly run it on your computer, you need to know how your code works and what it does.
  3. Indentation, tabs, and spaces: Python uses accurate indentation when displaying code. Indentation means that the code in that section is part of the above declaration and is not associated with another part of the code. Create an indent using four spaces instead of the Tab key.
  4. Comments- you will also refer to comments here. This is a very important element in programming. Even if you are the only one viewing the code, you need to add a comment about what is happening. Does this role you lose your life? Write a comment and help yourself or someone else see what's going on. Python Exception Class helps you to remove these errors.
  5. Loop Count: Note that in Python, loops do not count the last number specified in the range.
  6. Case-sensitive: Python is a case-sensitive programming language, so you need to know which variables to assign. For example, Lives = 10 is a different variable than lives = 10, and calling the wrong variable in your code can lead to unexpected results. Docker Health Check is also necessary.
  7. Brackets-Everyone forgets to include extra brackets that need to be added at the end of the statement. Python relies on routines that have as many closed brackets as open brackets, so the error in your code can be due to forgetting to count the brackets.
  8. Colon:Beginners tend to forget to add a colon at the end of a structural statement like this:

The colon separates the code and creates an indent to which the next code belongs.

  1. Operators: It is a common mistake to use the wrong operator. For example, if you want to compare two values, you need to use the equation operator (double equals ==). Using a single equal sign (=) is an assignment operator that places values ​​in variables (for example, lives = 10).
  2. Operating System-It is difficult to write code for multiple platforms, especially when you start using external operating system commands. For example, if your code needs to clear the screen, use cls for Windows. On the other hand, for Linux, you need to use clear. You need to resolve this by catching the error and issuing it with another command.