Beginner Question

Lee Harr missive at
Fri Mar 28 11:50:07 CET 2003

In article <8gSga.236197$L1.65045 at sccrnsc02>, Kevin Reeder wrote:
> On Thu, 27 Mar 2003 20:45:04 -0800, Lee Harr wrote:
>> Well... it is not just the last line, but I think the best way would be:
>> import random
>> def shuffle(self):
>>     random.shuffle(
> This one failed to work with the exception: Attribute error: shuffle.
> Probably something I'm not seeing.

Which version of python are you using?

I think random.shuffle was added in 2.0 or 2.1

If you are still using 1.5 or 1.6 I would definitely recommend
upgrading, especially if you are just starting to learn. There
are a lot of great new features that it would be good to learn
right from the start (just look how much simpler this example
becomes with the new method ;o)

>> How about this:
>> def shuffle(self):
>>     import random
>>     nCards = len(
>>     for i in range(nCards):
>>         j = random.randrange(i, nCards)
> This solution worked great. Is insert a list method?

Try this:


That will show you most of the list methods.

More information about the Python-list mailing list