We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Strings
- String Validators
- Discussions
String Validators
String Validators
Sort by
recency
|
1935 Discussions
|
Please Login in order to post a comment
this question taught me a lot.i didnt even know that python has a concept of for-else,i thought that we can use else with a preceding if but there's more to it. basically in a for-else,the else bloock is exceuted if the loop ran completely and was not interupted by a break statement.
s = input()
has_alnum = has_alpha = has_digit = has_lower = has_upper = False
for c in s: if c.isalnum(): has_alnum = True
print(has_alnum) print(has_alpha) print(has_digit) print(has_lower) print(has_upper)