@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 1233 / 12833)
There was an example of adding a list with extend () or + =
.
I made a code with ideone.
http://ideone.com/CVLeBv
alist = ['7of9', 'Kim', 'Janeway']
print(alist)
alist.extend(["B'Elanna"])
print(alist)
alist += ['Chakotay']
print(alist)
result
Success time: 0 memory: 9024 signal:0
['7of9', 'Kim', 'Janeway']
['7of9', 'Kim', 'Janeway', "B'Elanna"]
['7of9', 'Kim', 'Janeway', "B'Elanna", 'Chakotay']
Two methods (extend () or + =) are provided for one process.
It may be useful to have a choice when the code format is consistent.
Recommended Posts