I find that this works :
a = list(('i', 'am'))
a.append('a')
a
['i', 'am', 'a']
but not this :
b = list(('i','am')).append('a')
b
I find that this works :
a = list(('i', 'am'))
a.append('a')
a
['i', 'am', 'a']
but not this :
b = list(('i','am')).append('a')
b
b
isn't assigned the list; it is assigned the result of the append
method, which is None
.
Put another way, b = list(('i','am')).append('a')
is not interpreted as
(b = list(('i','am'))).append('a')
Starting in Python 3.8, you could write
(b := list(('i', 'am'))).append('a')
using the assignment expression operator :=
to get the desired effect, but I feel confident in claiming that would be considered poor style.