solutions

Largest key

Write a function that receives a dictionary with only String keys and returns the longest key in the dictionary. Example:

longest_key({'hello': 'World', 'abc': 123})  # hello
longest_key({})  # None

Test Cases

test one item - Run Test

def test_one_item():
    assert longest_key({'rmotr': 'Intro to Python'}) == 'rmotr'

test with no items - Run Test

def test_with_no_items():
    assert longest_key({}) == None

test with many items - Run Test

def test_with_many_items():
    assert longest_key({'abcd': 'XXYYZZ', 'ac': 'MMM'}) == 'abcd'