The code that I have so far is:
password = input("Please enter a password: ")
letter = len(password)
if letters <= 5:
print ("WEAK")
elif
I know the answer is probably really obvious but I just can't see it - what i need it to be able to see whether the letters are capitals. There is other stuff that I need aswell but I'm working through it one step at a time. Please help?
String has isupper function:
Use it as follow:
>>> 'e'.isupper()
False
>>> 'E'.isupper()
True
>>> 'Ennn'.isupper()
False
>>> 'EEE'.isupper()
>>> 'eee'.isupper()
False
>>> 'EEEEe'.isupper()
False
If you want to check if at lest one char is upper, you can use any
>>> any([x.isupper() for x in list('eeeeE')])
True
>>> any([x.isupper() for x in list('eeee')])
False
>>> any([x.isupper() for x in list('EEEE')])
True
Docs:
https://docs.python.org/2/library/stdtypes.html#str.isupper https://docs.python.org/2/library/functions.html#any
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.