Password validation Write a program password.py that reads a file containing multiple passwords and checks the validity of the passwords.
Password validation
Write a
Function name |
Function description |
Function input(s) |
Function return value(s) |
---|---|---|---|
validate() |
This function takes a password string as input and returns a boolean that determines if the password is valid or invalid. The requirements for a valid password are:
|
Password string |
Boolean |
main() |
This function prompts for a file of passwords. Next, it opens the file. Next, it checks for the validity of every password in the file using the function validate() and prints the validity of the password. |
None |
None |
Use the starter code here:
def validate(password):
"""
This function validates a password and returns a boolean that determines if the password is valid of invalid. """
is_valid = False
# todo
return is_valid
def main():
"""
This function prompts for a file of passwords. Next, it opens the file. Next, it checks for the validity of every password in the file using the function validate() and prints the validity of the password.
"""
filename = input("Enter the password file name: ")
print()
with open(filename, 'r') as content:
pass
# todo if __name__ == '__main__': main()
Here are example passwords that couldve been in a file to use:
Q1Wb62YXn8EdtP 32489962 dKaxKXlLpp gT00D2W62effecT 2622wgkOIHRkC Er~_6w`@ws'&d 2S)'8Dp9e Zw62>8}mh<_@NqW9G J+979K62//T! 3P7sam:vX62}W p5mn6209&RgFN@gX
Example
Enter the password file name: passwords.txt Q1Wb62YXn8EdtP is valid 32489962 is invalid dKaxKXlLpp is invalid gT00D2W62effecT is valid 2622wgkOIHRkC is valid Er~_6w`@ws'&d is invalid 2S)'8Dp9e is invalid Zw62>8}mh<_@NqW9G is valid J+979K62//T! is invalid 3P7sam:vX62}W is valid p5mn6209&RgFN@gX is valid |
Trending now
This is a popular solution!
Step by step
Solved in 3 steps