I have this code and I don't know why it doesn't give me the correct answer
list = [1]
a = [0,0,2,3,4]
for n in a
if n!= 0
list.push(n)
a.delete(n)
end
end
p list => [1,2,4]
p a => [0,0,3]
I don't understand why number didn't get added to list. When I tried to only use 'push' and not 'a.delete' I got the correct answers
list = [1,2,3,4]
a = [0,0,2,3,4]
What is going on?