Could you use instead `range` everywhere? `xrange` is an habit we should forget when ranges are rather small (and also because they are lazily evaluated since Python 3)