I am trying to make a function to detect how many digits, letter, spaces, and others for a string.
Here\'s what I have so far:
def count(x): leng
Following code replaces any nun-numeric character with '', allowing you to count number of such characters with function len.
import re len(re.sub("[^0-9]", "", my_string))
Alphabetical:
import re len(re.sub("[^a-zA-Z]", "", my_string))
More info - https://docs.python.org/3/library/re.html