반응형
Your task is simply to count the total number of lowercase letters in a string.
Examples
lowercaseCount("abc"); ===> 3
lowercaseCount("abcABC123"); ===> 3
lowercaseCount("abcABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"); ===> 3
lowercaseCount(""); ===> 0;
lowercaseCount("ABC123!@€£#$%^&*()_-+=}{[]|\':;?/>.<,~"); ===> 0
lowercaseCount("abcdefghijklmnopqrstuvwxyz"); ===> 26
Solution:
def lowercase_count(string: str) -> int:
return len([i for i in string if i.islower()])
import re
def lowercase_count(string):
return len(re.findall('[a-z]',string))
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1226. Alphabet war (0) | 2022.12.27 |
---|---|
1225. Switcheroo (0) | 2022.12.25 |
1223. validate code with simple regex (0) | 2022.12.23 |
1222. Formatting decimal places #0 (0) | 2022.12.23 |
1221. Name Shuffler (0) | 2022.12.21 |