Cracking the code book solution in python