I need to know why the following two blocks of code return different outputs. I have:
somelist = ['foo', 'bar']
somelist.append('baz')
print somelist
prints ['foo', 'bar', 'baz']
as expected. However,
print ['foo', 'bar'].append('baz')
prints None
. Thanks in advance!
EDIT: Thanks all. Is there a way to use the append
function and print
command in one line of code?