I don't understand this result - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: I don't understand this result (/thread-1595.html) |
I don't understand this result - Ponomarenko Pavlo - Jan-14-2017 >>> f = [].extend(['spam', 32, 44]) >>> type(f) <class 'NoneType'> RE: I don't understand this result - snippsat - Jan-14-2017 >>> f = [].extend(['spam', 32, 44]) >>> f >>> repr(f) 'None'You need to define a list fist,then extend it. >>> lst = [] >>> lst.extend(['spam', 32, 44]) >>> lst ['spam', 32, 44] RE: I don't understand this result - buran - Jan-14-2017 extend changes the list in place (and thus return None) >>> f = [].extend(['spam', 32, 44]) >>> type(f) <type 'NoneType'> >>> f=[] >>> f.extend(['spam', 32, 4]) >>> type(f) <type 'list'> >>> print f ['spam', 32, 4] RE: I don't understand this result - Kebap - Jan-15-2017 >>> f = [] + ['spam', 32, 44] >>> type(f) |