[Tutor] backslashes

max . dos.fool at gmail.com
Sun Jul 8 18:54:51 CEST 2007


hello i am writing a simple password tester that uses a word list and am
running into some problems when i read the words from a text file they are
written to the screen with a backslash at the end and i cant seem to find a
way to get rid of them

here is the script:

__name__="dictionary password tester"
__author__="max baseman (dos.fool at gmail.com)"
__version__="0.1"
__discription__="tests a password against a dictonary"
#############################################################

print
print
password=raw_input("password >")
passlist=open("/Users/max/passlist.rtf","r") # passlist is just a list of
50,000 words
guesses=0
for line in passlist:
    line=line.replace('\ ','') #heres what i was trying now
    guesses=guesses+1
    line=line.lower()
    print line
    if line==password:
        print
        print
        print"you password was",line,"and it took",guesses,"guesses"
        break





p.s i am about to look up how to type to python and not show the text for
the password bit but if anyone knows please explain
any help would be great thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070708/3bb219a0/attachment.htm 


More information about the Tutor mailing list