반응형
Filter the number
Oh, no! The number has been mixed up with the text. Your goal is to retrieve the number from the text, can you return the number back to its original state?
Task
Your task is to return a number from a string.
Details
You will be given a string of numbers and letters mixed up, you have to return all the numbers in that string in the order they occur.
Solution:
def filter_string(string: str) -> str:
return int("".join(s for s in string if s.isdigit())
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0206. Find the nth Digit of a Number (0) | 2023.02.07 |
---|---|
0205. pick a set of first elements (0) | 2023.02.05 |
0203. Parse float (0) | 2023.02.03 |
0202. Beginner Series #1 School Paperwork (0) | 2023.02.02 |
0201. Who ate the cookie? (0) | 2023.02.01 |