I am making a system in which when a user plays my game, it compares their score to what they have scored before by using a username and password. the info is stored in text file in the format: score*username*password
. I am trying to get those into different variables so that I can check them against other variables. this is the code I'm using. the problem is that the assigning of the variables doesn't work and I cant work out why
username = "hello"
password = "1234"
player_score = 40
file = open("yahtzee high scores.txt", "r")
lines = file.readlines()
file.close()
highscore = 0
highUser = ""
print(lines)
for line in lines:
score = ""
name = ""
passw = ""
findingScore = True
findingName = False
findingPass = False
for i in line:
if i != "*" and findingScore:
score += i
elif i != "*" and findingName:
name += i
elif i != "*" and findingPass:
passw += i
else:
print(name)
if findingScore:
findingName = True
findingScore = False
elif findingName:
findingName = False
findingPass = True
elif findingPass:
findingPass = False
if int(score) > highscore:
highscore = int(score)
highUser = name
highPass = passw
print(highscore)
print(highUser)