dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
79 lines
1.6 KiB
Markdown
79 lines
1.6 KiB
Markdown
---
|
|
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())
|
|
```
|