You can use `xrange` here.