How to say "I learned swim but I don't know how to swim"

Solution 1:

In your 'I x y' example x could be 'studied'. Unlike learn there is no assumption of success, just an effort to learn.

Of course if you studied but failed to learn, not mentioning that you failed until asked would count against you in an interview. But that's a bit out of scope (interviews.se?)

Solution 2:

First, the idiomatic way to say the first bit is "I learned to swim".

"I learned swimming" would be OK if "swimming" were being used to mean the sport or activity. This would be like saying "I learned horse-riding" meaning the activity rather than that you learnt to ride a horse, meaning you learnt how to stay in position and control your horse. But if I understand you right, you are talking about learning how to stay afloat and propel yourself through the water, so I'd recommend "I learnt to swim".

Now "learn" implies that you still had the knowledge that your teacher tried to teach you. Even "X taught me to swim" implies that, thanks to being taught, you learnt how to, so you had that skill at one time even if you can't swim any more.

So if, even after the swimming class, you never could swim, you might say "I took swimming classes, but I couldn't learn how to swim".

If after the swimming class, you could swim, but you can't swim now, then you might say "I learned how to swim, but I can't swim any more".