Home > other >  Problem sets _ strong password problems
Problem sets _ strong password problems

Time:11-26

Beginners Python (version 3.8.6), met a problem:
Write a function that USES a regular expression, to ensure that the incoming password string is strong password, strong password
Definition: length of not less than eight characters, and contains uppercase and lowercase characters, at least one number, you can
Will need to use more than a regular expression to test the string, in order to make sure its intensity,

I wrote a few lines of code, just also can answer this question, it is no matter what string needs to be input twice, can satisfy the condition of the second verification is successful,
StrongPW requirements: length> O=8, both upper and lower case,
At further containing one digit.
Both please enter your string:
1234 asddfjkdsf

The strings rose don 't meet requirement# 1.
Both please re - enter your string:
1234 asddfjkdsf
The strings rose meets requirements. Congratulations!

Please help me to answer is look at what went wrong, thank you!

Below is the code:

The import re

Print (" 'StrongPW requirements: length> O=8, both upper and lower case,
At further containing one digit. "')
Print (' both please enter your string: ')

Regex2Chk1=re.com running (r '[a-z] +')
Regex2Chk2=re.com running (r '[a-z] +')
Regex2Chk3=re.com running (r '[0-9] +')

Def regexCheck (strings) :
Strings=input ()

While True:
If the len (strings) & lt; 8:
Print (" 'The strings rose don' t meet requirement# 1. "')
Print (' both please re - enter your string: ')
Strings=input ()

If regex2Chk1. Search (strings)==None:
Print (" 'The strings rose don' t meet requirement# 2. "')
Print (' both please re - enter your string: ')
Strings=input ()

If regex2Chk2. Search (strings)==None:
Print (" 'The strings rose don' t meet requirement# 3. "')
Print (' both please re - enter your string: ')
Strings=input ()

If regex2Chk3. Search (strings)==None:
Print (" 'The strings rose don' t meet requirement# 4. "')
Print (' both please re - enter your string: ')
Strings=input ()

The else:
Print (' The strings rose meets requirements. Congratulations! ')

Break


EnteredStr=input ()

RegexCheck (enteredStr)

CodePudding user response:

Within the function using the input was a mistake, in just a matter of incoming parameters,

CodePudding user response:

This need feel with a variety of regular combination can realize the
 #! The/usr/bin/env python 
# - * - coding: utf-8 - * -
The import re
While True:
Test_passwd=input (" please enter a string match: no fewer than eight ")
If len (test_passwd) & gt;=8:
If re. Match (r '. *? [0-9] *? 'test_passwd) :
If re. Match (r '. *? [a-z]. *? 'test_passwd) :
If re. Match (r '. *? [a-z]. *? 'test_passwd) :
Print (" can meet the strength requirement!" )
The else:
Print (" does not contain lowercase letters, do not conform to the requirements ")
The else:
Print (" does not contain capital letters, is not in conformity with the requirements ")
The else:
Print (" does not contain Numbers, is not in conformity with the requirements ")
The else:
Print (" length less than 8 bits, does not conform to requirements ")

CodePudding user response:

 import re 

Print (" 'StrongPW requirements: length> O=8, both upper and lower case,
At further containing one digit. "')
Print (' both please enter your string: ')

Regex2Chk1=re.com running (r '[a-z] +')
Regex2Chk2=re.com running (r '[a-z] +')
Regex2Chk3=re.com running (r '[0-9] +')


Def regexCheck (strings) :
# strings=input ()

While True:
If the len (strings) & lt; 8:
Print (" 'The strings rose don' t meet requirement# 1. "')
Print (' both please re - enter your string: ')
Strings=input ()

If regex2Chk1. Search (strings)==None:
Print (" 'The strings rose don' t meet requirement# 2. "')
Print (' both please re - enter your string: ')
Strings=input ()

If regex2Chk2. Search (strings)==None:
Print (" 'The strings rose don' t meet requirement# 3. "')
Print (' both please re - enter your string: ')
Strings=input ()

If regex2Chk3. Search (strings)==None:
Print (" 'The strings rose don' t meet requirement# 4. "')
Print (' both please re - enter your string: ')
Strings=input ()

The else:
Print (' The strings rose meets requirements. Congratulations! ')

Break


EnteredStr=input ()

RegexCheck (enteredStr)
  • Related