I am having some trouble verifying the given data for 'user' against what is already in the users.txt file. An example of a line in the text file is...
('Ralph', '1a1dc91c907325c69271ddf0c944bc72')
Where 'Ralph' is what I want to compare against the users input for 'user'.
Here is my code so far:
#12/13/10 12:46 AM
#attempt to add new users to a users file
import md5
file = open('./users/users.txt', 'r')
user = raw_input("Please enter your username: ")
while line:
line = file.readline()
if line == user:
print 'error'
file.close()
passwort = raw_input("Enter your password: ")
#MD5 hashing password and writing
passwort = md5.md5(passwort).hexdigest()
info = user, passwort
info = str(info)
#writing the user's data
#a flag means to append (if it exists)
file = open('./users/users.txt', 'a')
file.write(info)
file.write('\n')
print line would return ('Ralph', '1a1dc91c907325c69271ddf0c944bc72')
but print line[0] prints '('
If somebody wouldn't mind and help me with this simple problem because I'm sure I'm missing something simple. Thanks for your time.