Letters as Numbers

Sometimes text is turned into a numeric code by replacing each letter with its position in the alphabet. Write alphabet_position, which takes a string text and converts every Latin letter to its number: a is 1, b is 2, and so on up to z as 26. Ignore all non-letter characters, and return the numbers as one space-separated string.

Примеры

Ввод
"The sunset sets at twelve o' clock."
Вывод
"20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11"
Ввод
"-.-'"
Вывод
""
Ввод
"abc"
Вывод
"1 2 3"

Нужно реализовать

def alphabet_position(text: str) -> str:

Теги

strings
PostgreSQLv16

Tu sa zobrazí výsledok spustenia kódu

Visible tests
1
Input
"The sunset sets at twelve o' clock."
Expected"20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11"
2
Input
"-.-'"
Expected""
3
Input
"abc"
Expected"1 2 3"
4
Input
"Z"
Expected"26"
5
Input
""
Expected""
6
Input
"'-.-"
Expected""
Focus radio
Paused · SomaFM · Fluid