>>> s = '12abcd405' >>> result = ''.join([i for i in s if not i.isdigit()]) >>> result 'abcd'
Here is what the above code is Doing:
1. We create a list comprehension that iterates over the string s.
2. For each character in s, we check if it is a digit.
3. If it is not a digit, we add it to the list.
4. Finally, we use the join() method to convert the list to a string.