We can use the pattern '\d.*[AZ]|[AZ].*\d' to search for records that have at least one capital letter and one number. Logically speaking, there are only two ways that the capital letter and number can appear in a string. Either the first letter, or the number after, or the number first, and the letter after.
Pipe | indicates "OR", so we will consider each side separately. \d.*[AZ] matches a number followed by a capital letter, [AZ].*\d matches any capital letter followed by a number.
words = ['Password1', 'password2', 'passwordthree', 'P4', 'mypassworD1!!!', '898*(*^$^@%&#abcdef'] for x in words: print re.search('\d.*[AZ]|[AZ].*\d', x)
source share