Attempt to index upvalue 'letter' (a nil value)

How can i solve this error? this is my code for the “letter”:

[lua]

for i= 7, #arr_str do

slot = display.newImageRect( “images/bg_slot.png”, 43, 43 )

slot.x = xPos; slot.y = yPos -40

slotgroup:insert( slot )

slot1 = display.newImageRect( “images/ans_slot.png”, 43, 43 )

slot1.x = xPos; slot1.y = yPos 

slotgroup:insert( slot1)

print(“ERROR”,arr_str[i])

letter = display.newImageRect(“letters/uc/”… arr_str[i] …".png",50,50)

letter.name = arr_str[i] 

letter.x = xPos; letter.y = yPos

letter.idBg = i

lettergroup:insert( letter)

xPos = xPos + gap

----------------------------Determine if correct answer and gain coins-------------------------------------------------------------------

local function checkAns()

   local str = “”

   local count = 0

   for i = 7 , rowMax do

    if name[i] then

    str = str…name[i]

    count = count + 7

    end

   end    

—position for correct letter--------------------------------------------------------------------------------------

local function listener(event)

   local letter = event.target

– myData.playSound(“letter2”)

   if not letter.isSelected then

selectletter(letter)  

   elseif not letter.isHinted then

       letter.y = letter.y + 40

       letter.isSelected = false

       letter.x = startpos + (letter.idBg-1) *35

       name[letter.idAns]= nil

       print(“removed”,letter.idAns,#name,name[1])

   end

  return true

end

   letter.isSelected = false

   letter:addEventListener(“touch”,listener)

end

end

[/lua]

Which line is failing? 

Found the error. Thanks for wanting to help…

There was an extra space all along.

Which line is failing? 

Found the error. Thanks for wanting to help…

There was an extra space all along.