Use spaces. Don’t EVER use tabs. Use a consistent number of spaces for indentation (the preferred number is 4). Use tabnanny as well:
python -m tabnanny myscript.py
The problem with your script is inconsistent indentation. Some places you indent 8 spaces, some 1, some 2, and some 4. Use 4 spaces for indentation, no tabs, throughout and you’ll be okay.
Configure your editor to use spaces, not tabs, and indent blocks by 4 spaces.
If you can’t do that, I don’t know what to say.