In [19]: s = 'BF' In [20]: list(map(chr, range(ord(s[0]), ord(s[-1]) + 1))) Out[20]: ['B', 'C', 'D', 'E', 'F']
The trick is to convert both characters to their ASCII codes, and then use range()
.
PS Since you need a list, the list(map(...))
construct can be replaced with a list comprehension.
source share