나는 이렇게 학습한다/Algorithm & SQL

0204. Filter the number

daco2020 2023. 2. 4. 21:25
반응형

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())


반응형