mercredi 28 novembre 2018

New string every time a loop runs

Looking to prove a sibling wrong about how long it can take a computer to guess a specific string by using Brute Force even with the correct number of characters put in. I can get the code to run but I cannot figure out how to get it to print a new string every time it runs. I'm sure I'm over looking something simple. Below are a couple examples of the code I've tried.

import string
import random

random=''.join([random.choice(string.ascii_letters+string.digits) for n in xrange(5)])

while True:
   if random != "Steve":
      print(random)
   if random == "Steve":
      print("Found")

This will continually print the same string over and over. I've also tried this without the while statement just the if and it doesn't seem to work.

I know enough that once random picks those 5 randoms characters it won't change until something makes it change but like I said I'm not sure how to do that. I've tried moving random to different places but doesn't work I just get different error messages.

Can someone help me out.




Aucun commentaire:

Enregistrer un commentaire