Understanding range() vs xrange() in Python

While learning Python, I came across range() and xrange(). They look similar, but there is an important difference, especially if you work…