0
This code is made to generate a password of X random numbers (1 in the case), and then loop random passwords until you get to the initial password, "bruteforce". Although it can generate the first password and the function to generate random passwords also work, the code does not detect when the password generated by the function is equal to the initial password. The problem must be quite trivial, I’m beginner.
import random
low = 'abcdefghijklmnopqrstuvwxyz'
upper = low.upper()
mix = low + upper
password_list = random.sample(mix, 1)
password = ''.join(password_list)
def random_bet():
try_list = random.sample(mix, 1)
guess = ''.join(try_list)
return guess
while random_bet() != password:
print(random_bet())
print(password)
print('Wrong')
if random_bet() == password:
print(random_bet(), password)
print('right')
break
Thank you very much, it worked
– Caio Bahlis