I have a function that takes a string as its input. The string can contain Integer numbers as well. I want to remove the spaces between the words and any integer that is greater than, for example, 5. How can I do this?
def my(str):
    x = [i for i in str]
    for items in x:
        if items == ' ':
            x.remove(items)
    new_items = [x for x in x if not x.isdigit()]
    return(new_items)
print(my('7 monkeys and 1 tiger'))
So far I have tried this. It removes both 7 and 1 from the string. Here is the output:
['m', 'o', 'n', 'k', 'e', 'y', 's', 'a', 'n', 'd', 't', 'i', 'g', 'e', 'r']
But I wanted to remove only 7 but not 1.
 
     
    