It is password generator program in python-3. It will auto generate the password in random char, after we want enter that password as input. If it is correct access is granted otherwise... But i have eof error in "if statement" it prints the denied option whatever input is given. Help to solve my code
import random
char = 'abcdefghijklmnopqrstuvwxyz1234567890'
length = input('password lenght?')
len = int(length)
for p in range(1):
pas = ' '
for c in range(len):
pas += random.choice(char)
g = pas
print (g)
code = input("Enter password :")
if g == code:
print("Access Granted")
else:
print("Access Denied")
You need to initialize pas
with empty string not with a space.
import random
char = 'abcdefghijklmnopqrstuvwxyz1234567890'
length = input('password lenght?')
len = int(length)
for p in range(1):
pas = ''
for c in range(len):
pas += random.choice(char)
g = pas
print (g)
code = input("Enter password :")
if g == code:
print("Access Granted")
else:
print("Access Denied")