The reason you're getting an error when passing 0 to this function is because the range
function in Python starts from 0 by default. Since the valid range for n
is from 1 to 64, passing 0 to the function will cause the n in range(1, 65)
condition to evaluate to False
, triggering the else
statement which raises the ValueError
.
To fix this, you can update the range to start from 1 by replacing range(1, 65)
with range(1, 65)
. Here's the corrected version of the function:
main.py89 chars2 lines
Now, when you pass 0 to the function, it will raise a ValueError
with the specified message.
gistlibby LogSnag