[].extend only accepts list?
Kannan Vijayan
kvijayan at calum.csclub.uwaterloo.ca
Sat Nov 27 01:08:13 EST 1999
Quinn Dunkan (quinn at groat.ugcs.caltech.edu) wrote:
> Is there any reason why the extend method of lists shouldn't accept any
> sequence?
the extend method checks to see if the argument is a list. You
can easily get past this by using the list() function
y = ["one", 2, "three"]
y.extend(list(("four", 5.0, 3*2)))
y -> ["one", 2, "three", "four", 5.0, 6]
you can use this method with any sequence, including strings, and tuples.
-kannan
More information about the Python-list
mailing list