이해는 제대로 된 거 같은데 출력이 안 됩니다
저 table 은
[(10, 10, 5, 'd'), (5, 0, 1, 'c'), (4, 8, 5, 'b'), (3, 4, 2, 'e'), (2, 4, 2, 'g'), (0, 2, 1, 'a'), (0, 1, 0, 'f')] 의 결과를 가지는 리스트입니다
# 메달 집계 결과로 히스토그램 만들기
def histogram():
t = [0] * 7
for item in table:
total = sum(item[:3])
t[total // 3] += 1
for i in range(7):
print(str(3*i), "~", str(3*i+2), ":\t", ("*" * t[i]))
저 histogram() 을 출력하면
>>> histogram()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "<input>", line 5, in histogram
IndexError: list index out of range
라고 하면서 에러가 뜨는데 무엇이 문제일까요?
comment