mercredi 12 juin 2019

Random number generator generates the same number

I get the same number using two different generators.

I've tried debugging but it didn't work as I intended because it generated the same result.

def roll2():
    global one,two,name1,name2
    print("----------------------")
    rounds2 = 0
    while one == two or two == one:
        choice1 = False
        choice2 = False
        rollone = random.randint(1,6)
        rolltwo = random.randint(1,6)
        while choice1 == False:
            choice=input(f"{name1} please input R or Roll to roll the dice.\n").lower()
            if choice == "r" or choice == "roll":
                print(f"{name1} has gotten a {rollone} from the roll")
                choice1 = True
        while choice2 == False:
            choice=input(f"{name2} please input R or Roll to roll the dice.\n").lower()
            if choice == "r" or choice == "roll":
                print(f"{name2} has gotten a {rolltwo} from the roll")
                choice2 = True
        rounds2 += 1
    one = rollone
    two = rolltwo
    return one,two,rounds2

Luke has gotten a 1 from the roll Lauren please input R or Roll to roll the dice. r Lauren has gotten a 6 from the roll Luke please input R or Roll to roll the dice. r Luke has gotten a 1 from the roll Lauren please input R or Roll to roll the dice. r Lauren has gotten a 1 from the roll Luke please input R or Roll to roll the dice.




Aucun commentaire:

Enregistrer un commentaire