Python: textwrap.wrap(), OrderedDict.fromkeys()
First, enter a text string, e.g. AABCAAADA
. Followed by a divisor integer, e.g. 3
.
AABCAAADA
3
The program returns:
AB
CA
AD
Notice how redundant letters are left out.
textwrap.wrap(S, N)
is used to separate AABCAAADA
into three equal parts: ['AAB', 'CAA', 'ADA']
.
for i in t:
u = ''.join(i)
u
stores the following:
AAB
CAA
ADA
''.join(OrderedDict.fromkeys(u))
is used to print the following. Notice how duplicate letters are left out.
AB
CA
AD