why list() cannot be extended?
Opened this issue · 3 comments
cp4 commented
you can use list like this:
numbers = [1, 7, 2, 34, 8, 7, 2, 5, 14, 22, 93, 48, 76, 15, 7]
mylist = list(numbers)
mylist.extend([42, 24])
print mylist
You got:
[1, 7, 2, 34, 8, 7, 2, 5, 14, 22, 93, 48, 76, 15, 7, 42, 24]
so far so good.
But if you do this:
numbers = [1, 7, 2, 34, 8, 7, 2, 5, 14, 22, 93, 48, 76, 15, 7]
mylist = list(numbers).extend([42, 24])
print mylist
You got a
None
why it would be that?
yzha3917 commented
list().extend() is not legitimate structure, so it returns in none.
YaDong ZHANG
On 1 Apr 2015, at 03:23, Max Wang notifications@github.com wrote:
I don't get it.
What's wrong indeed?
@yzha3917—
Reply to this email directly or view it on GitHub.