Skip to content

Latest commit

 

History

History
63 lines (37 loc) · 889 Bytes

Regex_count_lowercase_letters.md

File metadata and controls

63 lines (37 loc) · 889 Bytes

CodeWars Python Solutions


Regex count lowercase letters

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

Given Code

def lowercase_count(strng):
    pass

Solution 1

def lowercase_count(strng):
    i = 0
    for c in strng:
        if c.islower():
            i += 1
    return i

Solution 2

def lowercase_count(strng):
    return sum(a.islower() for a in strng)

See on CodeWars.com