# Problems with splice!/deleteat!

**URL:** <https://discourse.julialang.org/t/problems-with-splice-deleteat/73874>\
**Category:** New to Julia\
**Created:** [December 31, 2021, 7:43pm UTC](https://discourse.julialang.org/t/problems-with-splice-deleteat/73874 "2021-12-31T19:43:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbal091](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbal091/32/31976_2.png) [@fbal091](https://discourse.julialang.org/u/fbal091)\
**Post date:** [December 31, 2021, 7:43pm UTC](https://discourse.julialang.org/t/problems-with-splice-deleteat/73874/1 "2021-12-31T19:43:30Z")

</div>

hi there,  
i wrote a code that take a text and return the same text without the whitespaces and the punctuation. I can’t understand why i’m getting errors about the index of splice!: “attempt to access 7-element Vector{Char} at index [8]”. This is the code:

```julia
t = readlines("latino.txt")
s1 = join(t, ' ')
t1 = sort(split(s1))
t2 = []
for element in t1
    g = collect(element)
    for i in 1 : length(g)
        if isletter(g[i]) == false
           splice!(g, i)
        end
    end
    push!(t2, g)
    
end

```

[this is the text i chose](https://filesamples.com/samples/document/txt/sample3.txt)

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [December 31, 2021, 7:49pm UTC](https://discourse.julialang.org/t/problems-with-splice-deleteat/73874/2 "2021-12-31T19:49:08Z")

</div>

`length(g)` is evaluated once at the beginning of the loop, but you shorten `g` in the body of the loop, so you walk past the end of the new shortened `g`.
