What are the most common mistakes in Python programming?

  When it comes to programming languages, many people think of Python. In recent years, with the popularity of artificial intelligence, Python has become the language of choice for programming enthusiasts. Of course, when beginners learn Python to write programs, there will always be many small mistakes, so what are the most common mistakes in Python programming? Today I will summarize for everyone.

  1. Use incorrect indentation: Many Python features rely on indentation. When you create a new class, everything in the class will be indented under the class declaration.

  2. Punctuation errors: Placing punctuation in the wrong position will produce completely different effects. Remember that a colon must be added to the end of each structure statement.

  3. The use of logical operators: Most operators will not cause problems for developers, but logical operators will have problems. You must remember to use and determine when the two operands must be True.

  4. Use wrong capital letters: Python is case sensitive, MyVar is different from myvar and MYVAR, so you must check the capitalization.

  5. Create a one-to-one error on the loop: The loop will not calculate the last number you specify in the range. If you specify the range 1:12, you will actually get an output of values ​​between 1-11.

Guess you like

Origin blog.51cto.com/14596632/2540818