This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Error in random.shuffle
Type: crash Stage:
Components: Library (Lib) Versions: Python 3.0
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Viscaynot, georg.brandl
Priority: normal Keywords:

Created on 2007-09-05 02:20 by Viscaynot, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg55653 - (view) Author: Vizcaynot (Viscaynot) Date: 2007-09-05 02:20
In python 3.0a1 under Win XP SP2:
Typing next code:

import random
s=range(10)
random.shuffle(s)

I have next error:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python30\lib\random.py", line 262, in shuffle
    x[i], x[j] = x[j], x[i]
TypeError: 'range' object does not support item assignment

It does not happen in python 2.5
msg55657 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-09-05 06:20
Vizcaynot schrieb:
> New submission from Vizcaynot:
> 
> In python 3.0a1 under Win XP SP2:
> Typing next code:
> 
> import random
> s=range(10)

range() now returns an iterator, not a sequence, so random.shuffle() can't
work on it. Use list(range()) if you want a list.

Georg
History
Date User Action Args
2022-04-11 14:56:26adminsetgithub: 45447
2007-09-05 06:20:19georg.brandlsetstatus: open -> closed
nosy: + georg.brandl
messages: + msg55657
resolution: not a bug
2007-09-05 02:20:43Viscaynotcreate