What is a <class 'range'>
<p>Python3:</p>

<pre><code>string = range(10)
print("{}".format(type(string)))
</code></pre>

<p>The output: </p>

<pre><code>class 'range'
</code></pre>

<p>I am just curious about this class 'range'.
Could anyone explain?</p>

<p>But in Python2:</p>

<p>The output: </p>

<pre><code>class 'list'
</code></pre>

<p>Well, it is self explanatory</p>

<p>Python 3 added a new <a href="https://docs.python.org/3/library/stdtypes.html#range" rel="nofollow"><code>range</code></a> class to efficiently handle "an immutable sequence of numbers" (similar to Python 2's <a href="https://docs.python.org/2/library/stdtypes.html#typesseq-xrange" rel="nofollow"><code>xrange</code></a>). Python 2 does not have such a range class, so the <code>range</code> function just returns a list.</p>

python python-2.7 python-3.x range