Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How to check a string for specific characters?
I'm supposed to write a function that "Given a string s, return True if any character in that string is lowercase (between 'a' and 'z'), and False otherwise."
My code doesn't account for cases like ASDdFHU and ABCDeF
![Attachment image](https://s.yimg.com/tr/i/edd10ba04d3f4f6e9fba40f3948f104b_A.png)
3 Answers
- Mike TLv 55 years ago
import string
def any_lowercase(s):
for i in range(0,len(s)): #check each character using a for loop
if(ord(s[i]) >= 97 and ord(s[i]) <= 122): #if the character at s[i] is between 'a' and 'z' in ascii, it must be a lowercase letter so return true
return True
return False
- ChrisLv 75 years ago
Here's one way: http://ideone.com/ZPKLf5
any() is a function, you can't use it like you tried.