vendredi 9 novembre 2018

How to make a non list Loop that will select 4 random numbers from 1-10, and display them, but they cannot be the same?

import random
counter = 0
count = 0
counting = 0
valueOne = 0
valueTwo = 0
while counter ==0:
    playerOne = random.randint(1,10)
    number = random.randint(1,10)

About right here is where i get confused. It will run the loop, but every time #it runs, the random values get reset, and even if the first time it prints a #random number, the second time it might print the same and so forth.

    if number == playerOne:
        count = count + 1
    if number != playerOne:
        valueOne = playerOne

        if number != valueOne:

            print("lotto number",number)
            counting = counting + 1
        if counting >= 4:
            print("it took you this many trys",count)
            input('play again?')
            counting = 0
            count = 0




Aucun commentaire:

Enregistrer un commentaire