Open the file in question in your text editor
Indentation is how Python knows which code belongs together. You will get an error message when you make a mistake and don’t indent properly.
The easiest way to fix an indentation error is to open the file in question in your text editor. Text editors usually have a feature that allows you to “auto-indent” or “reformat” your code. This will fix most of your indentation errors.
If your text editor does not have an auto-indent feature, you can try to fix the indentation yourself. In most cases, you must add or remove a few spaces at the beginning of each line of code.
find the line that is causing the problem
Look through your code and find the line that is causing the problem. In this case, it is the line with the print statement. This line is causing an error because it is indented incorrectly. Python uses indentation to define code blocks, so if a line of code is not correctly indented, it will cause an error. In this case, you need to remove the indentation from the print statement so that it is on the same level as the rest of the code in the block.
delete the line or comment it out
delete the line or comment it out
In order to remove an indentation error in Python, you must either delete the erroneous line or comment it out. To comment out a line in Python, you must place a # symbol at the beginning of the line. This tells the Python interpreter to ignore that line and not attempt to run it as code.
save the file
Method 1:
Save the file in “UTF-8” encoding. This is the most failsafe method.
Method 2:
Check if there are any non-ASCII characters in the file. If so, replace them with their ASCII counterparts or remove them altogether. Then, save the file again.