Ask Your Question
2

Is it possible to extend the latin alphabet to AA, AB, AC....

asked 2021-03-22 16:19:40 +0200

Cyrille gravatar image

Perhaps one more time a stupid question or a Python one.

cand=build_alphabet(name="upper")
show(cand)

can list all letter in latin alphabet. But is there a possibility to construct extended alphabet as AA, AB, AC,...,AZ, BA,... as in Excel cells

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-03-22 18:04:42 +0200

slelievre gravatar image

updated 2021-03-24 18:09:07 +0200

Using build_alphabet is on the right track.

Words on that alphabet are a natural next step and provide exactly what is needed.

Define a function labels taking as an argument the desired number:

def labels(n):
    W = FiniteWords(build_alphabet(name='upper'))
    AZZ = (w for k in PositiveIntegers() for w in W.iterate_by_length(k))
    return [str(next(AZZ)) for _ in range(n)]

Use it to build a list of 60 labels:

sage: print(labels(60))
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB',
 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN',
 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH']
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-03-22 16:19:40 +0200

Seen: 65 times

Last updated: Mar 24