Takes input a function which returns True/False and keeps the items which return True.
passwords = ['72tK3', '6zW5P3', '1P3=it3?', 'i"u7/auX{m']
def strong_password(password):
return len(password) >= 8
allowed_passwords = list(filter(strong_password, passwords))
print(allowed_passwords)
Output:['1P3=it3?', 'i"u7/auX{m']
No comments:
Post a Comment