#fullname.py
from openpyxl import Workbook

excelfile = Workbook()
sheet = excelfile.active
allname = ['Prayut',
           'Taksin',
           'Parina',
           'Mongkolkit',
           'Prawit',
           'Tanatorn',
           'Chatchat',
           'Sudarat',
           'Anuthin',
           'Somchai']

checkname = {} #นับว่าแต่ละตัวอักษรมีเท่าไร

for nm in allname:
    #print(nm[0])

    if nm[0] not in checkname.keys():
        checkname[nm[0]] = 1
        sheet[nm[0]+'1'] =  nm
    else:
        checkname[nm[0]] = checkname[nm[0]] + 1
        sheet[nm[0] + str(checkname[nm[0]])] = nm

print(checkname)

excelfile.save('Allname.xlsx')
        
        



c483ae09f825ff61aeefa76c67564b8f67651749
<mask token>

<mask token>
for nm in allname:
    if nm[0] not in checkname.keys():
        checkname[nm[0]] = 1
        sheet[nm[0] + '1'] = nm
    else:
        checkname[nm[0]] = checkname[nm[0]] + 1
        sheet[nm[0] + str(checkname[nm[0]])] = nm
print(checkname)
excelfile.save('Allname.xlsx')

<mask token>
excelfile = Workbook()
sheet = excelfile.active
allname = ['Prayut', 'Taksin', 'Parina', 'Mongkolkit', 'Prawit', 'Tanatorn',
    'Chatchat', 'Sudarat', 'Anuthin', 'Somchai']
checkname = {}
for nm in allname:
    if nm[0] not in checkname.keys():
        checkname[nm[0]] = 1
        sheet[nm[0] + '1'] = nm
    else:
        checkname[nm[0]] = checkname[nm[0]] + 1
        sheet[nm[0] + str(checkname[nm[0]])] = nm
print(checkname)
excelfile.save('Allname.xlsx')

from openpyxl import Workbook
excelfile = Workbook()
sheet = excelfile.active
allname = ['Prayut', 'Taksin', 'Parina', 'Mongkolkit', 'Prawit', 'Tanatorn',
    'Chatchat', 'Sudarat', 'Anuthin', 'Somchai']
checkname = {}
for nm in allname:
    if nm[0] not in checkname.keys():
        checkname[nm[0]] = 1
        sheet[nm[0] + '1'] = nm
    else:
        checkname[nm[0]] = checkname[nm[0]] + 1
        sheet[nm[0] + str(checkname[nm[0]])] = nm
print(checkname)
excelfile.save('Allname.xlsx')

#fullname.py
from openpyxl import Workbook

excelfile = Workbook()
sheet = excelfile.active
allname = ['Prayut',
           'Taksin',
           'Parina',
           'Mongkolkit',
           'Prawit',
           'Tanatorn',
           'Chatchat',
           'Sudarat',
           'Anuthin',
           'Somchai']

checkname = {} #นับว่าแต่ละตัวอักษรมีเท่าไร

for nm in allname:
    #print(nm[0])

    if nm[0] not in checkname.keys():
        checkname[nm[0]] = 1
        sheet[nm[0]+'1'] =  nm
    else:
        checkname[nm[0]] = checkname[nm[0]] + 1
        sheet[nm[0] + str(checkname[nm[0]])] = nm

print(checkname)

excelfile.save('Allname.xlsx')
        
        


