--- id: 69bc6cb30c1d112a2e110a04 title: "Challenge 247: Last Letter" challengeType: 29 dashedName: challenge-247 --- # --description-- Given a string, return the letter from the string that appears last in the alphabet. - If two or more letters tie for the last in the alphabet, return the first one. - Ignore all non-letter characters. # --hints-- `get_last_letter("world")` should return `"w"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(get_last_letter("world"), "w")`) }}) ``` `get_last_letter("Hello World")` should return `"W"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(get_last_letter("Hello World"), "W")`) }}) ``` `get_last_letter("The quick brown fox jumped over the lazy dog.")` should return `"z"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(get_last_letter("The quick brown fox jumped over the lazy dog."), "z")`) }}) ``` `get_last_letter("HeLl0")` should return `"L"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(get_last_letter("HeLl0"), "L")`) }}) ``` `get_last_letter("!#$ er@R asd fT.,> 2t0e9")` should return `"T"`. ```js ({test: () => { runPython(` from unittest import TestCase TestCase().assertEqual(get_last_letter("!#$ er@R asd fT.,> 2t0e9"), "T")`) }}) ``` # --seed-- ## --seed-contents-- ```py def get_last_letter(s): return s ``` # --solutions-- ```py def get_last_letter(s): letters = [c for c in s if c.isalpha()] return max(letters, key=lambda c: c.lower()) ```