[Tutor] AttributeError: 'list' object has no attribute 'copy'

Kent Johnson kent37 at tds.net
Mon Nov 27 20:55:48 CET 2006


Keith Troell wrote:
> I'm a rank beginner. I am running Python 2.3.5 on the Terminal of Mac  
> OSX.
> 
> The Tutorial (5.1) mentions list.copy as a list method. When I run

Are you sure? I don't see it here:
http://www.python.org/doc/2.3.5/tut/node7.html#SECTION007100000000000000000

> 
> scores = [1, 2, 3]
> copy = scores.copy ()
> 
> I get: AttributeError: 'list' object has no attribute 'copy'

You can copy a list with the list() function or by slicing:
copy = list(scores)
or
copy = scores[:]

Kent



More information about the Tutor mailing list