A = {}    

for i in range(1,4+1):
 def parameter():
  return (i)
 variable = str(parameter())
 A[variable] = i

print A


B = {}

for i in range(1,4+1):
 def parameter():
  return (i)
 variable = str(parameter())
 def function(i):
  return(function[i] + function[i] + 1)
 B[variable] = function(i)

print B




python    2.7.5버전임

뭐가 틀린거? 파이썬 입문한지 얼마 안되서 뭐가틀린건지 모르겠음..


오류메세지

{Traceback (most recent call last):
  File "C:\Users\win7\Des\bete.py", line 20, in <module>
'1': 1, '3': 3, '2': 2, '4': 4}
    B[variable] = function(i)
  File "C:\Users\win7\Des\bete.py", line 19, in function
    return(function[i] + function[i] + 1)
TypeError: 'function' object has no attribute '__getitem__'