jeudi 31 janvier 2019

Passwords/username from a file

Ive recently been having trouble writing a program that involves taking the password and usename from a .txt file. So far i have written:

username_file = open("usernameTest1.txt","rt")
name = username_file.readlines()
username_file.close()
print(username_file)
print(name)
print(name[0])
print()

print(name[1])
Player1Name = name[0]
print(Player1Name)
nametry = ""
while nametry != (name[0]):
    while True:
        try:
            nametry = input("What is your Username player1?: ")
            break
        except ValueError:
            print("Not a valid input")

(The various prints are to help me to see what the error is) The password is succesfully extracted from the file however when it is put into a variable and put through an if statement it dosent work!

Any help would be much apreciated! Hopefully this is a simple fix!

Aucun commentaire:

Enregistrer un commentaire