-7
print'Your password must contain the following.. \n\n - at least 1 uppercase letter\n - at least 1 lowercase letter \n - at least 1 number \n - at least 7 characters' # Tells the user what the password requires
password = 0                                                    #Sets the password at 0 , gives an entry point into the while loop
while password <7:                                              #This while loop, while the password count is less than 7 execute the following
    s=raw_input('\nPlease choose a password: ')                 #Giving the password a variable
    errors = []                                                 #?????????????????????
    if not any(x.isupper() for x in s):                         #This is testing if there is NOT any uppercase characters in the string
        errors.append('\nERROR Your password needs at least 1 capital letter')
    if not any (x.islower() for x in s):
        errors.append('\nERROR Your password needs at least 1 lower case letter')
    if not any (x.isdigit() for x in s):
        errors.append('\nERROR Your password needs at least 1 number')
    if len(s)< 7:
        print '\nERROR Your password needs to be at least 7 characters'
    if errors:
        print '\n'.join(errors)
    if (any(x.isupper() for x in s) and any(x.islower() for x in s) and any(x.isdigit() for x in s) and len(s) >= 7):
        print '\n\nGreat, your all set up and ready to go. \n\nYour login:',login, '\nYour password:',s
        password = password +7
4

1 回答 1

2

在 python[]中意味着创建一个空列表。你也可以使用error = list()它也是一样的。然后你将该列表分配给一个名为的变量名error

error = []

稍后,您使用error.append()which 意味着将元素放在引用 name 的列表的末尾error

于 2013-06-17T11:04:32.220 回答