Python Forum
randint stops changing values in a loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
randint stops changing values in a loop
#5
(Jan-29-2019, 07:10 PM)Naito Wrote: the problem is that the value of ranint is a constant and not random while looping in a while loop.

I could not replicate your problem:

import random
rounds = 0
while rounds < 3:
        dice1 = random.randint(1, 6)
        dice2 = random.randint(1, 6)
        dice3 = random.randint(1, 6)
        dice4 = random.randint(1, 6)
        dice5 = random.randint(1, 6)
        dice6 = random.randint(1, 6)
        print(dice1, dice2, dice3, dice4, dice5, dice6)
        rounds += 1

1 5 5 4 1 3
5 4 2 5 2 5
4 4 2 4 1 4
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
randint stops changing values in a loop - by Naito - Jan-28-2019, 08:11 PM
RE: randint stops changing values in a loop - by perfringo - Jan-30-2019, 08:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pip stops waiting for python walker 6 1,063 Nov-28-2023, 06:55 PM
Last Post: walker
  random numbers, randint janeik 2 574 Nov-27-2023, 05:17 PM
Last Post: janeik
  Unexpected output while using random.randint with def terickson2367 1 516 Oct-24-2023, 05:56 AM
Last Post: buran
  Loop through values and compare edroche3rd 6 695 Oct-18-2023, 04:04 PM
Last Post: edroche3rd
  Loop through json file and reset values [SOLVED] AlphaInc 2 2,148 Apr-06-2023, 11:15 AM
Last Post: AlphaInc
  [SOLVED] [Linux] Script in cron stops after first run in loop Winfried 2 932 Nov-16-2022, 07:58 PM
Last Post: Winfried
  Creating a loop with dynamic variables instead of hardcoded values FugaziRocks 3 1,501 Jul-27-2022, 08:50 PM
Last Post: rob101
  How do loop over curl and 'put' different values in API call? onenessboy 0 1,229 Jun-05-2022, 05:24 AM
Last Post: onenessboy
  Loop through values in dictrionary and find the same as in previous row Paqqno 5 1,914 Mar-27-2022, 07:58 PM
Last Post: deanhystad
  How to add for loop values in variable paulo79 1 1,456 Mar-09-2022, 07:20 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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