import random sbc = 'abc' passlen = 3 passwd = ''.join(random.sample(sbc,passlen)) while 1: #NOW HOW DO I COUNT HOW MUCH ITERATION DOES IT TAKES TO MATCH THE STRING if passwd == 'abc': print 'password matched' break print 'bye'
counter = 0 while 1: passwd = ''.join(random.sample(sbc,passlen)) if passwd == 'abc': print('password matched') break print(passwd, "does not match") counter += 1 print(counter, "iterations")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)