I don't really know what the general opinion of using the for loop variable afterwards is.  I find the for-else somewhat elegant but actually think AssertionError makes sense here because it is checking an invariant (it should be impossible for the value not to fall into one of the buckets unless there is a bug in the code).