0π
You have miss placed the argument in method reverse it .
it will work.
But this also matched if you set symbol in your string.
so, i suggest you apply this things :
pwd =βtest5456β³
pwd.isalnum():
This method will only work for if your string contain string or digit.
if you want strongly want your password contain both numeric and string than this code will help you.
test = "anil13@@"
new = tuple(test)
data = list(new)
is_symb =False
is_digit = False
is_alpha = False
for d in data :
if d.isdigit() :
is_digit = True
if d.isalpha():
is_alpha = True
if not d.isdigit() and not d.isalpha():
is_symb =True
break
if is_symb == False and is_digit == True and is_alpha == True:
print "pwd matchd::::"
else :
print "pwd dosen't match..."
Note :This code strongly work for numeric & symbol
Regards,
Anil
2π
You reversed the arguments of match
re.match(pattern, string, flags=0)
It should be
match = re.match(num, pwd)
1π
You can do this to find out if the string is alphanumeric
pwd = "asdf67AA"
if pwd.isalnum():
# password is alpha numeric
else:
# password is not alpha numeric
- [Answered ]-Elastic Beanstalk failed to update local Git configuration
- [Answered ]-Backbone.js for in-browser page layout editor?
- [Answered ]-Django Form 'list' object has no attribute 'iterator'
- [Answered ]-Django Multiple db with read only
- [Answered ]-Content is null after the first dict()
0π
This is very simple answer and it is better to use regex for validation instead of wired if else condition.
import re
password = raw_input("Enter Your password: ")
if re.match(r'[A-Za-z0-9@#$%^&+=]{6,}', password):
print "Password is match...."
else:
print "Password is not match...."
#6 means length of password must be atleast 6
- [Answered ]-Generating unique random field in Django or PostgreSQL
- [Answered ]-Incorporating react redux into django
-1π
you can do it by using isalnum() method of python
just by doing
pwd.isalnum()
it will tell wthether a number is alphanumeric or not and then will hit the if condiion
- [Answered ]-How to pass variable to exception middleware with Django?
- [Answered ]-Django access m2m field attribute from a queryset
- [Answered ]-How to associate a generated file with a Django model
- [Answered ]-How to match begin URL with REGEX in Django