0
줄 대신에 'z'를 사용하여 줄 끝을 표시하십시오.파이썬 계산 문자 통계
def getLetIndex(pline, k):
return pline[k]
print("work with lists or arrays")
list = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
k=0
while k < 26:
list[k]=0
k +=1
print("list[1]=", list[1])
mline=input("enter a sentence=>")
print("you have entered=", mline)
k=0
while k < 26:
k+= 1
oneChar = getLetIndex(mline, k)
if oneChar == 'z':
break
num1 = ord(oneChar)
print("char=", oneChar, "char-num=", num1)
if num1 != 32: # not space
list[num1-97+1] += 1
print("letter statistics are below")
k=0
while k < 26:
print(list[k])
k +=1
print("list[1]=", list[1])
마지막 while 루프에서'print (list [k])'를'print { "} {{}"로 변경하십시오. – inspectorG4dget