Not putting correctly in array

ptl=[[0,3],[1,5],[2],[3,14],[4,0],[5,0],[6,15],[7,9],[8,7],[9,11],[10,16],[11,6],[12],[13,9],[14],[15,14]]
    ps=ptl.sample(3)
    
    types=Array(0..20)
    pt=(ps[0]+ps[1]+ps[2])
 
    for i in 0..pt.length()
        types[pt[i]]=[[19],[]]
    end
   
    p types
    for i in 0..ptl.length()
        for j in 0..pt.length()
            if (ptl&ptl).length()>0
                ptl.delete_at(i)
            end
        end
    end
    pw=ptl.sample(3)
    pwt=ptlweak[0]+ptlweak[1]+ptlweak[2]
    
    types[17]=[[pwt],[pt]]
    for i in 0..pwt.length()
        types[pwt[i]]=[[][19]]
    end 
  types[pt[i]]=[[19],[]] throws an error as to can't assign to that array. How do I get around that?