10 Python errors that are common to beginners

As soon as you learn Python for the first time, understanding the meaning of Python error messages can be a bit complicated. Please refer to the following for error hints that you often see.

1) I forgot to add it at the end of if, elif, else, for, while, class, def.

Error hint: SyntaxError: invalid syntax The error occurs in the following code. 1.png

2) Use of "=" and "="

Error hint: SyntaxError: invalid syntax "=" Is an assignment operator, and "=" is a comparison operation. The error occurs in the following code. 2.png

3) I forgot to call len () in the for loop

Error hint: TypeError: ‘list’ object cannot be interpreted as an integer The index typically iterates over the elements of list or string. To do this, you need to call the range () function. Remember to return the len value instead of returning this list. The error occurs in the following code. 3.png

4) change the string value

Error hint: TypeError: ‘str’ object does not support item assignment string is an immutable data type and the error occurs in the following code. 4.png

5) Connect values other than strings to strings

Error hint: TypeError: Ca n’t convert ‘int’ object to str implicitly The error occurs in the following code. 5.png

6) I forgot to add "'" at the beginning and end of the string

Error hint: SyntaxError: EOL while scanning string literal Error Occurs with the following code. 6.png

7) Use Python keywords as variable names

Error hint: SyntaxError: EOL while scanning string literal Python keywords cannot be used as variable names. This error occurs in the following code: 7.png

8) The method name is misspelled

Error hint: AttributeError: ‘str’ object has no attribute ‘lowerr’ This error occurs in the following code: 8.png

9) The reference exceeds the maximum index of the list

Error hint: IndexError: list index out of range This error occurs in the following code: 9.png

10) Use range () to create a list of integers

It's important to remember that range () actually returns a "range object" instead of a list value. Error hint: TypeError: ‘range’ object does not support item assignment This error occurs in the following code: 10.png

Recommended Posts

10 Python errors that are common to beginners
Python that I would like to recommend to programming beginners
3 Reasons Beginners to Start Python
~ Tips for beginners to Python ③ ~
Five useful Python data types that are easy to forget
For beginners, how to deal with common errors in keras
python beginners tried to find out
Regular expressions that are easy and solid to learn in Python
[Python] I tried to explain words that are difficult for beginners to understand in an easy-to-understand manner.
Answer to AtCoder Beginners Selection by Python3
[Python] How to deal with module errors
[Note] Terms that are difficult to remember
Heroku deployment of the first Django app that beginners are addicted to
Memo # 4 for Python beginners to read "Detailed Python Grammar"
The fastest way for beginners to master Python
Updated to Python 2.7.9
Variable naming anti-patterns that beginners tend to do
Python for super beginners Python for super beginners # Easy to get angry
Python beginners tried to code some energy drinks
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part7 / 22]
Memo # 3 for Python beginners to read "Detailed Python Grammar"
Memo # 1 for Python beginners to read "Detailed Python Grammar"
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part 4/22]
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part3 / 22]
Try to calculate RPN in Python (for beginners)
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part 1/22]
List of links that machine learning beginners are learning
[Python] Solution to the problem that elements are linked when copying a list
Memo # 2 for Python beginners to read "Detailed Python Grammar"
Note that Python list comprehensions are always confusing
Memo # 7 for Python beginners to read "Detailed Python Grammar"
Beginners practice Python
Introduction to Programming (Python) TA Tendency for beginners
Memo # 6 for Python beginners to read "Detailed Python Grammar"
How to make Python faster for beginners [numpy]
Python beginner's note
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part 6/22]
Memo # 5 for Python beginners to read "Detailed Python Grammar"
"Backport" to python 2
Points that are easy to make mistakes when using lambda during Python loop processing
[For beginners] How to use say command in python!
Python beginners try adding basic auth to Django admin
How to convert Python # type for Python super beginners: str
[For beginners] How to study Python3 data analysis exam
Syntax that Perl users tend to forget in Python
Python beginners talk about how to remember this much
Makes you think that Python regular expressions are great
[Python] tkinter Code that is likely to be reused
[Python] pandas Code that is likely to be reused
[Python] A convenient library that converts kanji to hiragana
I felt that I ported the Python code to C ++ 98.
Python # How to check type and type for super beginners
WebDriver methods that Python beginners were looking for first
[Linux] How to monitor logs that are constantly added
Python Beginner's Guide (Functions)
How to install Python
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Rewrite Python2 code to Python3 (2to3)
Python classes are slow
[Tips] Dealing with errors that occur when trying to install Python 3 series less than 3.5.3 with pyenv