Check for indentation error in python
python -m tabnanny yourfile.py
Then if you are using PyCharm as text editor then
go to Code , reformat code
There will be similar options in other text editors as well