a=list().append("hello") vs a=list(); a.append("hello") in python?
list, python
Solution
`list()` does indeed return an empty list (`[]`), but the `append` method operates on a list in-place - it changes the list itself, and doesn't return a new list. It returns `None` instead.
For example:
>>> lst = []
>>> lst.append('hello') # appends 'hello' to the list
>>> lst
['hello']
>>> result = lst.append('world') # append method returns None
>>> result # nothing is displayed
>>> print result
None
>>> lst # the list contains 'world' as well now
['hello', 'world']
Problem
I have ``` try: a = list().append('hello') ``` but `a` is `NoneType` ``` try: b = list() b.append('hello') ``` and `b` is a `list` type I think `list()` returns a list object, and `list().append('hello')` will use the return list to do append, but why is the value of `a` `None`?