First, the common errors:
1, missed the end of the colon , such as an if statement, a loop statement, the function is defined
2, indentation error , when the indentation is not indented
3, the English symbols written in Chinese symbols, such as: '' (),
4, string concatenation, the string of numbers and splicing together
5, there is no definition of variables
6, "==" and "=" mix
7, indent the Tab key and space mix
Second, knowledge unskilled causing bug :
Such as: 1, the index list is started from 0, not 1; and
2, append () function can only add a parameter, such as a.append ( 'A')
Third, the idea is not clear cause bug :
Method: 1, the feeling will be problems with # code snippet commented;
2, using a print () statements, showing key steps of the operation result;
3, according to the results print out, step by step to find and solve problems;
Fourth, passive pit out :
You can use try ... except ..... Statement ( the specific content you want to indent ) to solve
After using a try ... except ..... Statement
try .... except .... the three uses:
1, with the if .... elif ..... elif .... the same, except you can try back with more
2, after the except abnormalities may be two or more together , wherein a long touch, to execute the code contained:
3, a conventional error base class , assumed not want to provide very fine tips, can use this statement in response to the general error: