Solution 1

def max_char(a_string):
    max_found = None
    for char in a_string:
        if max_found is None or char > max_found:
            max_found = char

    return max_found or ''

Max character

Write a function max_char that receives a string and returns the "maximum" character in it. Max is defined as a < b < ... < z ignoring uppercase chars (all strings provided will be lowercase). Important: If the string received is empty, the result should be an empty string. Example:

max_char('azg')  # 'z'
max_char('')  # ''

Test Cases

test with empty string - Run Test

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

test with a single char - Run Test

def test_with_a_single_char():
    assert max_char('j') == 'j'

test with many chars - Run Test

def test_with_many_chars():
    assert max_char('janbfthahdag') == 't'
def max_char(a_string): pass