Guess the pattern

Use the test to guess the pattern used by the function and implement it using Python.

Test Cases

test your function - Run Test

def test_your_function():
    assert my_function('Python') == 'X_Python_X'
    assert my_function('Hello World') == 'X_Hello World_X'
    assert my_function('?') == 'X_?_X'

Solution 1

def my_function(a_string):
    return 'X_' + a_string + '_X'
def my_function(a_string): pass