Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
repeating for loop
#3
If you want the numbers from 0 to n in random order without repeats, use shuffle:

numbers = list(range(n + 1))
random.shuffle(numbers)
I don't see how you could get an IndexError, since there are no list indexes in your code. If the above does not solve your problem, please post the full text of the error.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
repeating for loop - by Kaldesyvon - Dec-06-2018, 07:23 PM
RE: repeating for loop - by buran - Dec-06-2018, 07:30 PM
RE: repeating for loop - by ichabod801 - Dec-06-2018, 07:34 PM
RE: repeating for loop - by nilamo - Dec-06-2018, 07:56 PM
RE: repeating for loop - by buran - Dec-06-2018, 07:56 PM
RE: repeating for loop - by ichabod801 - Dec-06-2018, 08:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is 2/3 not just .666 repeating? DocFro 4 1,887 Dec-12-2023, 09:09 AM
Last Post: buran
  repeating a user_input astral_travel 17 5,016 Oct-26-2022, 04:15 PM
Last Post: astral_travel
  if else repeating Frankduc 12 4,705 Jul-14-2022, 12:40 PM
Last Post: Frankduc
  factorial, repeating Aldiyar 4 3,900 Sep-01-2020, 05:22 PM
Last Post: DPaul
  number repeating twice in loop JonnyEnglish 3 4,408 Nov-24-2019, 09:23 AM
Last Post: ThomasL
  Repeating equations Tbot100 2 4,148 May-29-2019, 02:38 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020