Feb-10-2017, 07:53 AM
(This post was last modified: Feb-10-2017, 11:40 PM by ichabod801.)
# Now, create a Python file called forgetful.py . Imagine your friend was very forgetful and always seemed to enter his email password incorrectly. You want to write a Python program that takes all his incorrect password entries, stores it in a list, then records
# all his incorrect password entries in a text file called wrongpasswords.txt.
# Example: your friends password is 'rusty'. But he enters 'rusty123', 'Rusty', 'rustless' before finally remembering his password is 'rusty' and entering it correctly.
# In this situation wrongpasswords.txt should read this exactly:
# Incorrect password 1: rusty123
# Incorrect password 2: Rusty
# Incorrect password 3: rustless
# Correct password entered on 4th entry.
# The program should ask the user for input by saying 'Please enter your password'. The correct password will always be 'rusty' but the user can of course enter any String.
# Good luck!
i am suppose to write entered passwords to the file till the "Correct" one is inputted which is "rusty" but i cant seem to get it right and ive spent over a couple of hours trying.. please help this is what i have coded:
# all his incorrect password entries in a text file called wrongpasswords.txt.
# Example: your friends password is 'rusty'. But he enters 'rusty123', 'Rusty', 'rustless' before finally remembering his password is 'rusty' and entering it correctly.
# In this situation wrongpasswords.txt should read this exactly:
# Incorrect password 1: rusty123
# Incorrect password 2: Rusty
# Incorrect password 3: rustless
# Correct password entered on 4th entry.
# The program should ask the user for input by saying 'Please enter your password'. The correct password will always be 'rusty' but the user can of course enter any String.
# Good luck!
i am suppose to write entered passwords to the file till the "Correct" one is inputted which is "rusty" but i cant seem to get it right and ive spent over a couple of hours trying.. please help this is what i have coded:
enteredPass = raw_input("Enter your password: ") incorrectPass= file("wrongpasswords.txt","w") counter = 0 for i in range(0, counter+1): if enteredPass != "rusty": counter = counter +1 incorrectPassO = open("wrongpasswords.txt","w") incorrectPassO.write("Incorrect password" +str(counter)+": " + enteredPass + "\n") incorrectPassO.close() enteredPass = raw_input("Enter your password: ") else: incorrectPassO = open("wrongpasswords.txt","w") incorrectPassO.write("Correct password entered on the " + str(counter)+"th entry") incorrectPassO.close()