Change count into an array of letters, python
Question: I am struggling with an idea I want put into a python script. I'm not even
sure how to ask the most appropriate question as I've been surfing through the
net trying to find what I want with no luck.

Basically, I have a script that does a simple calculation:

    
    
    divider = int(math.ceil(df.scale / 3000))
    

This is because I want ' divider' to return the value divided by 3000 and
always rounded up. I want to use that value to help me return letters.

So, it goes like this:

if 1 returns then I want a to return 'A' if 2 returns, then I want to create
'A', 'B' if 3 returns, then I want to create 'A', 'B', 'C' and so on....

My end result is, that I want to save some files. 'divider' will determine how
many files I want to save and then each file will recursively be named with
the letter in it (i.e. FileA, FileB, FileC...)

Ok, I know my question isn't exactly well put together, but I'm struggling
with the logic, so if you need some clarity, please let me know.


Answer: Do you mean something like:

    
    
    for i in range(int(math.ceil(df.scale / 3000))):
      # i will contain 0, 1, 2, ...
      # letter will contain 'A', 'B', 'C', ...
      letter = chr(ord('A') + i)
    

Or if you need the actual list:

    
    
    [chr(ord('A') + i) for i in range(int(math.ceil(df.scale / 3000)))]
    

You can also use
[`string.ascii_uppercase`](http://docs.python.org/library/string.html#string.ascii_uppercase)
for a list of uppercase letters and slice it as you need:

    
    
    from string import ascii_uppercase
    
    print list(ascii_uppercase)[:int(math.ceil(df.scale / 3000))]
    

