mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
shift/unshift
This commit is contained in:
@@ -292,7 +292,7 @@ ZeroDivisionError: Fraction(0, 0)</samp></pre>
|
||||
</ol>
|
||||
|
||||
<blockquote class='note compare perl'>
|
||||
<p><span class=u>☞</span><code><var>a_list</var>.insert(0, <var>value</var>)</code> is like the <code>shift()</code> function in Perl. It adds an item to the beginning of the list, and all the other items have their positional index bumped up to make room.
|
||||
<p><span class=u>☞</span><code><var>a_list</var>.insert(0, <var>value</var>)</code> is like the <code>unshift()</code> function in Perl. It adds an item to the beginning of the list, and all the other items have their positional index bumped up to make room.
|
||||
</blockquote>
|
||||
|
||||
<p>Let’s look closer at the difference between <code>append()</code> and <code>extend()</code>.
|
||||
|
||||
Reference in New Issue
Block a user