Skip to navigation

say_last_digits

View as MarkdownOpen in Claude

Return the last n digits of text, one word each, as one group: for “a card ending in” or “the account ending in”. Separators in text are ignored. The words come from say_digits().

from signalwire.speech import say_last_digits

Parameters

text
str | intRequired

The number, with any separators.

n
intDefaults to 4

How many of the last digits to say. Raises ValueError unless it’s a whole number of at least 1.

zero
strDefaults to zero

Keyword-only. The word for 0, such as "oh".

Returns

str — The words, or "" when text has no digits.

Example

from signalwire.speech import say_last_digits
print(say_last_digits("4111 1111 1111 1234"))
# one two three four
print(say_last_digits("+1 415 555 0102", n=2, zero="oh"))
# oh two

Part of the speech helpers module.