python code from udacity class