Solving exercise43 from the book "Learn Python the Hard Way" by Zed A. Shaw