BEWARE I am not a programmer, so have a close look at this patch.
Your code is not Python 3 compatible, as "xrange()" (Python2) now is "range()" (Python3) and "range()" (Python2) now is "list(range())" (Python 3).
I changed the code according to https://www.daniweb.com/software-development/python/threads/322517/xrange-in-python-3#post1375926 but I did not test it as I do not know how :)
BEWARE I am not a programmer, so have a close look at this patch. Your code is not Python 3 compatible, as "xrange()" (Python2) now is "range()" (Python3) and "range()" (Python2) now is "list(range())" (Python 3).
I changed the code according to https://www.daniweb.com/software-development/python/threads/322517/xrange-in-python-3#post1375926 but I did not test it as I do not know how :)