Closed alexpovel closed 4 years ago
Thanks. The project was written for a 10-digit combo, but just before going to print the editor suggested making it work for any combo. I forgot to update this line. It will be corrected in the 3rd edition.
Please check out the webpage for other errata: https://nostarch.com/impracticalpythonprojects.
In the line prefaced by bullet-point number 7, it reads:
which means that we try a digit on that index that depends on the combination length, instead of just picking a digit from 0 to 9. It works in the example, since the combination is 10 digits long, so that the line evaluates to
randint(0, 10 - 1)
. However, it fails to solve all combinations whereholds true, e.g. an 8 occurs in a combination of length 5.
While writing this, I noticed the issue is fixed here.
I am leaving this issue for others to find and as a reminder that this should be corrected in future print versions.