Make sure you take the time to understand error messages. They can help you a lot.
Work backward from the error. Many times an error message is caused by something that has happened before it in the program. Always remember that python evaluates a program top to bottom.