← Back to challenges

Filter a String

PythonHardstringsregexinterviewlanguage_fundamentals

Instructions

Mubashir needs your help to count uppercase letters, lowercase letters, numbers and special characters in a given string.

Create a function which takes a string txt and returns a list of numbers with count of uppercase letters, lowercase letters, numbers and special characters.

Examples

filter_string("*$(#Mu12bas43hiR%@*!") ➞ [2, 6, 4, 8]
# 2 uppercase letters
# 6 lowercase letters
# 4 numbers
# 8 special characters

filter_string("^^Sample^^%$#12379") ➞ [1, 5, 5, 7]

filter_string("**Airforce1**") ➞ [1, 7, 1, 4]

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Omnipresent Value