I just began teaching myself python today while bored in class so I apologize if my mistake is very simple. I want to have the user type a 4 digit password, then have the program try to crack said password. This is what I have,
import random
from random import *
print("Password Cracker")
password=input("Type a 4 digit password ")
e=password[0]
f=password[1]
g=password[2]
h=password[3]
print("Your password is " + password)
n=0
while True:
a=randint(0,9)
b=randint(0,9)
c=randint(0,9)
d=randint(0,9)
n+=1
if (a==e and b==f and c==g and d==h):
print("Password Cracked")
print("Password took " + {4} + " tries to crack")
break
The a,b,c, and d variables are not working as intended. I was hoping that every time the loop runs they would be updated until eventually, they equal the user inputed password. If anyone can let me know what's wrong with the code that would be much appreciated.