반응형
Your boss decided to save money by purchasing some cut-rate optical character recognition software for scanning in the text of old novels to your database. At first it seems to capture words okay, but you quickly notice that it throws in a lot of numbers at random places in the text.
Examples (input -> output)
'! !' -> '! !'
'123456789' -> ''
'This looks5 grea8t!' -> 'This looks great!'
Your harried co-workers are looking to you for a solution to take this garbled text and remove all of the numbers. Your program will take in a string and clean out all numeric characters, and return a string with spacing and special characters ~#$%^&!@*():;"'.,? all intact.
Solution:
def string_clean(s):
return "".join(i for i in s if not i.isdigit())
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1214. Find the position! (0) | 2022.12.14 |
---|---|
1213. Exclamation marks series #1: Remove an exclamation mark from the end of string (0) | 2022.12.13 |
1211. Maximum Product (0) | 2022.12.11 |
1210. Bumps in the Road (0) | 2022.12.11 |
1209. Grasshopper - Combine strings (0) | 2022.12.09 |