Robotics & Artificial Intelligence
Write a function to check the complexity of a password string. A strong password should contain at least 8 characters, including uppercase letters, lowercase letters and digits.
Python String Manipulation
3 Likes
Answer
def check_password_complexity(password):
if len(password) < 8:
return "Weak Password"
has_upper = False
has_lower = False
has_digit = False
for ch in password:
if ch.isupper():
has_upper = True
elif ch.islower():
has_lower = True
elif ch.isdigit():
has_digit = True
if has_upper and has_lower and has_digit:
return "Strong Password"
else:
return "Weak Password"
password = input("Enter a password: ")
result = check_password_complexity(password)
print(result)Output
Enter a password: Abc12345
Strong Password
Answered By
2 Likes
Related Questions
Write a Python program for the following task:
Take a string entered by the user and check if it begins with the letter "a" or not. If it begins with "a", the user is prompted that it is the first name on the list. If it does not begin with "a", the user is prompted that the string does not begin with the letter "a".
Write a Python program to check that a given string is a palindrome or not.
Write a Python program to reverse a string.
Take a string and create a substring that contains all the unique characters from the list.