What does the following error mean?
Unindent does not match previous indent [6,3] Can't find the error on "Expected ")" Pylance [16,9]. Import "Numpy" could not be resolved
What does the following error mean?
Unindent does not match previous indent [6,3] Can't find the error on "Expected ")" Pylance [16,9]. Import "Numpy" could not be resolved
"Pylance reportUndefinedVariable" had solved by editing the last two lines in settings as follows.
settings >> code actions not saved >> edit in settings.json
"editor.codeActionsOnSave": {},
"source.addMissingImports": {}
Based on your image,
You need a )
at the end of line 15. You are properly closing format(...)
but you never close input(...)
.
Whatever is on line 16 needs to be commented out. You can comment out a line in Python with the #
character as the leftmost character.
Lines 17 and on are indented too far. The quick way to "un-indent" them is to highlight the lines, hold shift
, and press tab
. The body of your function definitions show_score
and start_game
are also indented too far. Use a single indent.
Based on your message you are improperly importing numpy
somewhere in your code. You should ensure you spell it correctly, such as import numpy
or import numpy as np
(casing matters). If you have not yet installed the numpy package you can do so with pip install numpy
or conda install numpy
depending on your Python package manager.
As a rule of thumb you should be very careful with indentation in Python, as it is part of the syntax. You are using inconsistent indentation throughout your entire file. Only indent following definitions, conditions such as if
or else
, after try
and catch
, and for the body of loops such as for
and while
. Other cases also exist for indentation. If you are familiar with other languages such as C, C++, Java, C#, and many more, then you may be used to using {}
for scoping. In Python scope is indicated by indentation, which is why it's important to be careful.
If you update your question to actually provide your code as text and not a screenshot, we can help you fix your indentation issues.