Foreach Array Function Python