How to make a continuous alphabetic list python (from a-z then from aa, ab, ac etc)

前端 未结 6 1207
时光取名叫无心
时光取名叫无心 2020-11-30 08:53

I would like to make a alphabetical list for an application similar to an excel worksheet.

A user would input number of cells and I would like to generate list. For

6条回答
  •  迷失自我
    2020-11-30 09:23

    Print the set of xl cell range of lowercase and uppercase charterers

    Upper_case:

    from string import ascii_uppercase
    import itertools
    def iter_range_strings(start_colu):
        for size in itertools.count(1):
            for string  in itertools.product(ascii_uppercase, repeat=size):
                yield "".join(string)
    
    input_colume_range = ['A', 'B']
    input_row_range= [1,2]
    for row in iter_range_strings(input_colume_range[0]):
        for colum in range(int(input_row_range[0]), int(input_row_range[1]+1)):
            print(str(row)+ str(colum))
        if row ==  input_colume_range[1]:
            break
    
    

    Result:

    A1
    A2
    B1
    B2
    

提交回复
热议问题