#python #sicp
the add function in the operator module (and the + operator) yields a list that
is the concatenation of the added arguments
If you want to change selection, open original toplevel document below and click on "Move attachment"
Parent (intermediate) annotation
Open itlists can be added together and multiplied by integers. For
sequences, addition and multiplication do not add or multiply elements, but
instead combine and replicate the sequences themselves. That is, the add function in the operator module (and the + operator) yields a list that
is the concatenation of the added arguments. The mul function in operator (and the * operator) can take a list and an integer k to
return the list that consists of k repetitions of the original list.Original toplevel document
2.3 Sequenceshe built-in len function returns the length of a sequence.
Below, digits is a list with four elements. The element at index 3 is 8.
>>> digits = [1, 8, 2, 8]
>>> len(digits)
4
>>> digits[3]
8
Additionally, <span>lists can be added together and multiplied by integers. For
sequences, addition and multiplication do not add or multiply elements, but
instead combine and replicate the sequences themselves. That is, the add
function in the operator module (and the + operator) yields a list that
is the concatenation of the added arguments. The mul function in
operator (and the * operator) can take a list and an integer k to
return the list that consists of k repetitions of the original list.
>>> [2, 7] + digits * 2
[2, 7, 1, 8, 2, 8, 1, 8, 2, 8]
Any values can be included in a list, including another list. Element selection
can be applied multiple times in orSummary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details