Append X

Write a function append_x that receives a string and appends the character 'X' to it ONLY if the string is not empty:

append_x('hello')  # hellox
append_x('')  # ''

Test Cases

test with valid string - Run Test

def test_with_valid_string():
    assert append_x('abc_') == 'abc_x'

test with empty string - Run Test

def test_with_empty_string():
    assert append_x('') == ''

Solution 1

def append_x(a_string):
    if a_string:
        return a_string + 'x'
    return a_string
def append_x(a_string): pass