To fix Python indentation you can use the reindent.py script that you find in the Tools/scripts/ directory of your Python installation:
Also, change the Python (.py) files to use 4-space indents and no hard tab characters. Try to trim excess spaces and tabs from ends of lines, and also remove empty lines at the end of files. One important point always ensures the last line ends with a newline.
To know more about this you can have a look at the following video:-
If you wish to learn more about Python, visit the Python tutorial and Python Certification course by Intellipaat.