Skip to content

Latest commit

 

History

History
43 lines (25 loc) · 573 Bytes

Help_Bob_count_letters_and_digits.md

File metadata and controls

43 lines (25 loc) · 573 Bytes

CodeWars Python Solutions


Help Bob count letters and digits

Bob is a lazy man.

He needs you to create a method that can determine how many letters and digits are in a given string.

Example:

"hel2!lo" --> 6
"wicked .. !" --> 6
"!?..A" --> 1

Given Code

def count_letters_and_digits(s):
    pass

Solution

def count_letters_and_digits(s):
    return len([char for char in s if char.isdigit() or char.isalpha()])

See on CodeWars.com