code from https://developers.google.com/edu/python/