작성
·
5
0
# 11.Dict Items Sum
d = {'a': 17,'b': 114,'c': 247, 'd': 362, 'e': 220, 'f': 728, 'g': -283, 'h': 922}
# 방법1
total = 0
for i in d.values():
total += i
print(f'ex1 결과 : {total}')
# 방법2
print(f'ex2 결과 : {sum(d.values())}')
# 방법3
print(f'ex3 결과 : {sum([d[item] for item in d])}') # 괄호 제외
TypeError Traceback (most recent call last)
Cell In[13], line 15
11 print(f'ex1 결과 : {total}')
14 # 방법2
---> 15 print(f'ex2 결과 : {sum(d.values())}')
18 # 방법3
19 print(f'ex3 결과 : {sum([d[item] for item in d])}')
TypeError: 'int' object is not callable
인트가 호출이 안 된다고 뜨는데 이유가 뭔지 알 수 있을까요?
답변