0 out of 464 challenges solved

Move Numbers to End

Write a Python function `move_numbers_to_end(s: str) -> str` that takes a string `s` as input and returns a new string where all numeric characters are moved to the end of the string, preserving the order of both the non-numeric and numeric characters.

#### Example Usage
```python [main.nopy]
move_numbers_to_end("I1love143you55three3000thousand")
# Output: "Iloveyouthreethousand1143553000"

move_numbers_to_end("Avengers124Assemble")
# Output: "AvengersAssemble124"

move_numbers_to_end("Its11our12path13to14see15things16do17things")
# Output: "Itsourpathtoseethingsdothings11121314151617"
```
def move_numbers_to_end(s: str) -> str:
    """
    Move all numeric characters in the string to the end while preserving the order of other characters.

    Args:
        s (str): The input string.

    Returns:
        str: The modified string with numbers moved to the end.
    """
    # Initialize variables to store non-numeric and numeric characters
    non_numeric = []
    numeric = []

    # Iterate through each character in the string
    for char in s:
        # Check if the character is a digit
        if char.isdigit():
            # Append to numeric list
            numeric.append(char)
        else:
            # Append to non-numeric list
            non_numeric.append(char)

    # Combine non-numeric and numeric characters
    return ''.join(non_numeric) + ''.join(numeric)