mardi 8 décembre 2020

have to randomly generated number to match in python?

Hi all wish y'all stay safe!

I'm trying to figure out how to write a simple code to count how many tries it takes to have 2 random numbers to match using pythong randint(), while keeping count how many times it takes.

my thought is :

ran1 = random.randint(1,10)

ran2 = random.randint(1,10)

count = 0
while ran1 != ran2:
  count = count+1
  print(count)
  if ran1 == ran2:
    break
    print(count)

does this make sense? something is wrong but i dont know what... it just keeps going and no stop lol

thank you!




Aucun commentaire:

Enregistrer un commentaire