Content deleted Content added
Citation bot (talk | contribs) Altered pages. Added doi. Formatted dashes. | Use this bot. Report bugs. | Suggested by Spinixster | Category:Programming constructs | #UCB_Category 54/70 |
→Python: lang="pycon" |
||
Line 101:
===Python===
In [[Python (programming language)|Python]], use the list method "extend" or the infix operators <code>+</code> and <code>+=</code> to append lists.
<syntaxhighlight lang="
>>> l = [1, 2]
>>> l.extend([3, 4, 5])
>>> l
print l + [6, 7]▼
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 6, 7]
</syntaxhighlight>
Do not confuse with the list method "append", which adds a '''single''' element to a list:
<syntaxhighlight lang="
>>> l = [1, 2]
>>> l.append(3)
>>> l
[1, 2, 3]
</syntaxhighlight>
===Bash===
|