Python Forum
RNG; One variable must not be equal to another
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RNG; One variable must not be equal to another
#1
I am still studying about importing modules, and suddenly I came with an idea of a random number generator which will generate a six-number combination out of numbers within a specified range. I am going to insert a specific portion of my codes

from random import *

die1 = randint(1,42)
die2 = randint(1,42) 
die3 = randint(1,42)
die4 = randint(1,42)
die5 = randint(1,42)
die6 = randint(1,42)

print("For 6/42: ", die1, "-", die2, "-", die3, "-", die4, "-", die5, "-", die6)
I want to make the resulting numbers non-repeating, which means if die1 picked 5, the other variables must not pick 5. That goes for the other variables as well. How will I make it? The book I am using as reference haven't mentioned how to do so.
Reply


Messages In This Thread
RNG; One variable must not be equal to another - by DavidRobinsons - Oct-09-2018, 04:48 AM

Forum Jump:

User Panel Messages

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