Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to separate characters, Numbers and Special characters from given string with python

# Python 3 program to split an alphanumeric
# string using STL
def splitString(str):
    upper = ""
    lower = ""
    num = ""
    special = ""
    for i in range(len(str)):
        if (str[i].isdigit()):
            num = num + str[i]
        elif (str[i] >= 'A' and str[i] <= 'Z'):
            upper = upper + str[i]
        elif (str[i] >= 'a' and str[i] <= 'z'):
            lower += str[i]
        else:
            special += str[i]

    print(upper)
    print(lower)
    print(num)
    print(special)

splitString(input("Type: "))
 
PREVIOUS NEXT
Tagged: #How #separate #Numbers #Special #characters #string #python
ADD COMMENT
Topic
Name
2+9 =