+ 1

Password Validation 3.0

Is there a better option to check for special characters without looping over a custom list? https://code.sololearn.com/cHZerh8WUO8i/?ref=app

15th Mar 2020, 8:04 PM
Boseka
Boseka - avatar
8 ответов
+ 3
Oh sorry I wanted to ask if there is a better way to check if the password contains any special characters, without looping over a custom list
15th Mar 2020, 8:09 PM
Boseka
Boseka - avatar
+ 3
Use regular expressions(re module) import re password = raw_input("Enter string to test: ") if re.match(r'[A-Za-z0-9@#$%^&+=]{10,}', password): # match else: # no match https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2475/
15th Mar 2020, 8:27 PM
Ore
Ore - avatar
+ 3
What is the difference between raw_input and input? And what {10,} stands for?
15th Mar 2020, 8:36 PM
Boseka
Boseka - avatar
+ 3
Boseka raw_input is for python 2. It tells python 2 to return a string instead of evaluating it. In python 3 just use input. {10,} means more than 10 characters
16th Mar 2020, 7:03 AM
Ore
Ore - avatar
+ 2
Boseka What is your question ?
15th Mar 2020, 8:07 PM
BroFar
BroFar - avatar
20th Oct 2020, 6:14 AM
イデリセ{非活性}
イデリセ{非活性} - avatar
0
password = list(input()) str = " ".join(password) #a string with space b/w the items import re symb = re.findall("[!@#\$%&\*]+", str) num = re.findall(r"[0-9]+", str) filt = filter((lambda x: x in symb,str), (password)) print ("Strong" if len(symb) >= 2 and len(num) >= 2 and len(password) >=7 else "Weak")
5th Dec 2021, 8:15 PM
Mas'ud Saleh
Mas'ud Saleh - avatar
- 1
no
24th Mar 2020, 4:02 AM
ML1022020 JOSHUA ETHAN CHEW WEI XUAN
ML1022020 JOSHUA ETHAN CHEW WEI XUAN - avatar