So i want to get the time execution. Need it to make condition that checks that execution time of code. If the seconds get more than 5 then it goes to next lines of code. Working on passwords creator that makes passwords that ends/starts with specified symbols in string. So, if I will get "freeze" of printing when the print function will not print anything because of none solutions then i need that time execution.
while True:
sample = random.sample(string, lenght)
x = ''
if x in passwords:
continue
else:
if starts["enabled"] == True or ends['enabled'] == True:
counter += 1
x = ''.join(sample)
if starts['enabled'] == True and ends['enabled'] == True:
if x.startswith(starts['startWith']) and x.endswith(ends['endWith']):
if x in passwords:
continue
else:
print(f"# {counter}. {x}")
passwords.append(x)
if starts['enabled'] == False and ends['enabled'] == False:
if x in passwords:
continue
else:
print(f"# {counter}. {x}")
passwords.append(x)
if starts['enabled'] == True and ends['enabled'] == False:
if x.startswith(starts['startWith']):
if x in passwords:
continue
else:
print(f"# {counter}. {x}")
passwords.append(x)
if starts['enabled'] == False and ends['enabled'] == True:
if x.endswith(ends['endWith']):
if x in passwords:
continue
else:
print(f"# {counter}. {x}")
passwords.append(x)
else:
counter += 1
x = ''.join(sample)
print(f"# {counter}. {x}")
if timeit.timeit('print(f"# {counter}. {x}")', number=1) >= 5:
print("Thats all..")
pass
if len(passwords) == len_pass or len(passwords) <= len_pass:
if len(passwords) == len(string) ** lenght:
print("\n")
print(f"{passwords}\n")
break
if len(passwords) == len_pass:
print("\n")
print(f"{passwords}\n")
break