How do you make a list inclusive?
<p>I have homework that asks me to make a list from 1 to 52 inclusive. (for a deck of cards) I was just wondering how do you make a list inclusive?</p>

<p>I know how to make a list, just am not sure how to make it inclusive. I searched on here for awhile and couldn't really find anything helpful.</p>

<p>Use built-in <a href="https://docs.python.org/2/library/functions.html#range" rel="nofollow"><code>range()</code></a> function which returns the list of numbers. For example:</p>

<p><strong>In Python 2.7</strong>:</p>

<pre><code># To get numbers from 0 to n-1. Here, 'n' = 10
&gt;&gt;&gt; range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

# To get numbers from m to n-1. Here, 'm' = 5, 'n' = 10
&gt;&gt;&gt; range(5, 10)
[5, 6, 7, 8, 9]

# To get numbers from m to n-1 with step of s. Here, 'm' = 5, 'n' = 10, 's' = 2
&gt;&gt;&gt; range(5, 10, 2)
[5, 7, 9]
</code></pre>

<p><strong>In Python 3</strong>: </p>

<p>You need to explicitly type-cast it to <code>list</code> as: </p>

<pre><code>&gt;&gt;&gt; list(range(10))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
</code></pre>

python list python-3.x