In Python, indentation matters, and changes between lines have meaning. The last line of the code you posted is indented compared to the one before when it should not be. This is so wrong that it is a syntax error rather than an error which would happen at run time. If the fix is not obvious, post back, and provide as much description as you can as to what you think your code does and why it should be working.
Due to the reasons discussed here
we will be moving to python-forum.io
on October 1, 2016.
This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.