Hi All,
I'm using Windows Vista with Python 2.5. I need the code to check for case sensitive letters and digits, but something isn't right with it.
The code is below: - # -*- coding: cp1252 -*-
-
from easygui import *
-
-
accounttype=buttonbox("Would you like to create an account or login?", "Password Storage System Pro", choices=["Login","New Account"])
-
-
if accounttype=="Login":
-
multpasswordbox("Enter Your Account Information", "Login", ["User ID","Password"])
-
msgbox("Thank you for using Password Storage System Pro, \nPlease Try Again Later.")
-
if accounttype=="New Account":
-
newaccount=multpasswordbox("Enter Your Account Information", "New Account", ["User ID","Password"])
-
confirm=passwordbox("Please Validate Your Password", "Password")
-
while newaccount[1]==confirm:
-
msgbox("Thank you for using Password Storage lolSystem Pro")
-
password=confirm[1]
-
i=0
-
cap=0
-
low=0
-
dig=0
-
while i<len(password):
-
if password[i] >= "A" and password[i] <= "Z":
-
cap=cap+1
-
if password[i] >= "a" and password[i] <= "z":
-
low=low+1
-
if password[i] >= "0" and password[i] <= "9":
-
dig=dig+1
-
i=i-1
-
if cap>0 and low>0 and dig>0:
-
print "Thank You for registering"
-
-
print cap
-
print low
-
print dig
-
-
if newaccount[1]!=confirm:
-
msgbox("Your Passwords did not match. Try again please.")
-
confirm=passwordbox("Please Validate Your Password", "Password")
-
password=confirm[1]
-
i=0
-
cap=0
-
low=0
-
dig=0
-
while i<len(password):
-
if password[i] >= "A" and password[i] <= "Z":
-
cap=cap+1
-
if password[i] >= "a" and password[i] <= "z":
-
low=low+1
-
if password[i] >= "0" and password[i] <= "9":
-
dig=dig+1
-
i=i-1
-
-
-
print cap
-
print low
-
print dig
1 2773 bvdet 2,851
Expert Mod 2GB
Following are a some different approaches that may help you. - import re
-
-
pattU = re.compile(r'[A-Z]')
-
pattL = re.compile(r'[a-z]')
-
pattD = re.compile(r'[0-9]')
-
-
word = 'AdjiV560dfRGh'
-
-
print pattU.findall(word)
-
print pattL.findall(word)
-
print pattD.findall(word)
-
-
print len(pattU.findall(word))
-
-
>>> ['A', 'V', 'R', 'G']
-
['d', 'j', 'i', 'd', 'f', 'h']
-
['5', '6', '0']
-
4
- import string
-
-
word = 'AdjiV560dfRGh'
-
print len([letter for letter in word if letter in string.ascii_lowercase])
-
print len([letter for letter in word if letter in string.ascii_uppercase])
-
print len([letter for letter in word if letter in string.digits])
-
-
>>> 6
-
4
-
3
-
>>>
Instead of duplicating inline code, you can use a function - # Function returns True if word contains upper case, lower case and digits
-
# Otherwise returns false
-
def validate_word(word):
-
tt = (len([letter for letter in word if letter in string.ascii_lowercase]), \
-
len([letter for letter in word if letter in string.ascii_uppercase]), \
-
len([letter for letter in word if letter in string.digits]))
-
if 0 in tt: return False
-
return True
-
-
print validate_word('guenhfnm58976')
-
print validate_word('guenhfASZnm58976')
-
-
>>> False
-
True
-
>>> if validate_word('guenhfASZnm58976'):
-
... print 'Success'
-
... else:
-
... print 'Failure'
-
...
-
Success
-
>>>
Sign in to post your reply or Sign up for a free account.
Similar topics
by: O'Neal Computer Programmer |
last post by:
*** First of all, if there is a previous post on Temple of Elemental
Evil, please provide a link to that/them so in order to create a
larger resource on this game. Thanks! (Merci) ;-) ***
Temple...
|
by: Iwan van der Kleyn |
last post by:
Please ignore if you are allergic to ramblings :-)
Despite a puritan streak I've always tried to refrain from language wars
or syntax bickering; call it enforced pragmatism. That's the main...
|
by: Simon Brunning |
last post by:
QOTW: "Not tested but confident should be an oxymoron for a
programmer." - Peter Otten
(Asked "Is this unsurprising if I look at it right?") - "Yes; in
general this is true across many domains...
|
by: Paul Smith |
last post by:
This doesn't seem like it should be *that* difficult, but after
quite some time trying to figure it out, I'm still banging my
head against the wall.
My objective is to examine the exact...
|
by: J. Muenchbourg |
last post by:
I'm doing a few tests with simple .net scripts, and I noticed that I
display the following error message at ErrMessage.Text if I don't enter
"BLUE" in capital letters into my input textbox:
...
|
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 396 open ( -5) / 3354 closed (+12) / 3750 total ( +7)
Bugs : 864 open (-32) / 6087 closed (+52) / 6951 total (+20)
RFE : 226 open...
|
by: siggi |
last post by:
@Ben Sizer
Hi Ben,
in January I received your message re Pygame and Python 2.5:
As a Python (and programming ) newbie allow me a - certainly naive -
question:
|
by: Bart |
last post by:
Why is C case sensitive?
I know it's a bit late to change it now but there would seem to be far
more advantages in ignoring letter case in source code.
In real life such a situation would be...
|
by: bsagert |
last post by:
I downloaded BeautifulSoup.py from http://www.crummy.com/software/BeautifulSoup/
and being a n00bie, I just placed it in my Windows c:\python25\lib\
file. When I type "import beautifulsoup" from...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |