NameError: name ‘xrange‘ is not defined [How to Solve]

The reason is that my Python version is Python 3.8, while the xrange() function is in Python 2.0 For a function in X, in Python 3, the implementation of range () is the same as that of xrange (), so there is no special xrange (). Therefore, when this problem is encountered, there are two methods to solve it.


1: if you want to run the program in Python 3, change all xrange() functions to range().

2: put the program with this problem in Python 2.X version of the environment can be run

Read More: