The problem with this is fear of failure. If kids consider a skill worthwhile, from programming to sport to violin, and they see how good one can be (which can be hard to avoid especially for music) they will get fear of failure.
The next thing they'll tell you is they wish to stop. You cannot talk a kid out of fear of failure. I've never made the least bit of headway.
You shouldn't let them stop, and even force them to practice long enough (like >15 minutes, I'm not talking hours) that they forget about fear of failure and enjoy the next 15 minutes. Maybe even get them into the situation that there's nothing but the violin or some puzzle in code they don't understand for 5 minutes or so. Sport is good for this. If they do Judo and there is a duel, that's 2 minutes they will be focusing on the opponent. Somehow people don't easily get tired of this, and of course they focus.
It's all a balance. Should you let them struggle or give them answers directly? Should you give them opponents that are easy or hard ? Too easy? Too hard? Should you practice very directly or let them choose direction (they inevitably choose unattainable targets, so it's not as easy as you're thinking, but you may be able to guide them to a reasonable choice). Should you push them, maybe even "punish" them (take away cell phone for example)? I've known my kids to literally ask for that (taking away cell phone until they've completed homework or some practice).
And everything works like those opponents in Judo. The more they fight, the harder and stronger the opponent can be while they still learn. At 10 some can take "normal" adults and at 13-14 or so some kids are very liable to win against adults double their weight. But even "meta" this works. The more you push them, the harder you can push them without negative consequences and you should build this up over time.
It's all a balance. In every one of those questions there is a horrible answer that goes way too far ... on both sides of the equation. There is way too much practice and there is way to little practice, and it's even different per kid, when they're ill or feeling well, and how old they get. Otoh, as long as you're somewhere in the middle, it doesn't matter as much as you'd think where exactly you are in the middle. And you can pick one or two, but no more, where you have a slightly more extreme choice.