I am programming a dice game that only allows authenticated users to play, I have a method of appending and creating a password to a file. But I cannot search for a specific password that the user enters. My main goal for the section of the program is to create an 'if' statement that checks if the computer has found the specific password or not.
I am new to using the find statement, I have looked through many questions and examples over the past few days to no avail - I cannot get my head around how it would work with my code.
def Lock_Screen():
print("Welcome")
print("Log in(1) or Sign up(2)")
User_Choice = input("")
if User_Choice == "1":
print("Input your three-digit code:")
UserInput = input(str(""))
x = open("PasswordList.txt" , "r")
x.find(Userinput)
if x.find(UserInput):
Start_Screen()
elif User_Choice == "2":
Password = random.randint(100,999)
f = open("PasswordList.txt" , "a+")
x = open("PasswordList.txt" , "r")
PasswordList = x.read()
while Password == PasswordList:
Password = random.randint(100,999)
print("This is your password: " , Password)
f = open("PasswordList.txt" , "a+")
f.write(str(Password))
f.close()
Lock_Screen()
else:
print("That was not a valid answer")
Lock_Screen()
Lock_Screen()
The .find statement is suppose to find the variable but it just returns with an error message.