0 out of 464 challenges solved

Replace Characters in String

Write a Python function `replace_characters(input_string: str, target_char: str, replacement_char: str) -> str` that takes a string `input_string`, a character `target_char`, and another character `replacement_char`. The function should return a new string where all occurrences of `target_char` in `input_string` are replaced with `replacement_char`.

#### Example Usage
```python [main.nopy]
replace_characters("hello world", "o", "a")
# Output: "hella warld"

replace_characters("test case", "t", "p")
# Output: "pesp case"

replace_characters("example", "z", "x")
# Output: "example" (no change as 'z' is not in the string)
```
def replace_characters(input_string: str, target_char: str, replacement_char: str) -> str:
    """
    Replace all occurrences of target_char in input_string with replacement_char.

    Args:
        input_string (str): The original string.
        target_char (str): The character to be replaced.
        replacement_char (str): The character to replace with.

    Returns:
        str: The modified string with replacements.
    """
    # Your code here
    pass