samedi 4 juin 2022

how to add a condition to a random choice python [closed]

import random
import time
from threading import Thread

pswrod = "reza1300"
char = ["r", "e", "z", "a", "1", "3", "0"]


class Guess_password():
    def __init__(self, psword, char):
        self.psword = psword
        self.char = char
        self.guess = ""
        self.tried = []

        self.app_loop()

    def app_loop(self):
        while True:
            Thread(target=self.guessing, args=()).run()
            Thread(target=self.guessing, args=()).run()
            Thread(target=self.guessing, args=()).run()
            Thread(target=self.guessing, args=()).run()
            
    def guessing(self):
        self.guess = random.choices(char)
        self.new_guess = ""
        
        for i in self.guess:
            self.new_guess += i
        if self.new_guess not in self.tried:
            self.tried.append(self.new_guess)
            print("this is guess : ", self.new_guess)
            print("this is tried :", self.tried)
        if self.new_guess == self.psword:
            print("this is password: ", self.new_guess)
            time.sleep(5)


Guess_password(char, pswrod)




Aucun commentaire:

Enregistrer un commentaire