I would say "I learned to drive in 6 months" emphasize how long it took to learn to drive & "I learned to drive for 6 months" emphasize how long it lasted and the continuity of the action.
Here are some of my studies:
In some dictionaries, they say
You use in to say how long something takes.
He learned to drive in six months.
The food was all eaten in a few minutes.
Be Careful!
Don't say that something lasts or continues 'in' a period of time. Say that it lasts or continues for that time.
I have known you for a long time.
I worked for the same company for ten years.
But in other dictionaries, they see "in" as "after a particular length of time" not "how long it takes"
in: after a particular length of time
to return in a few minutes/hours/days/months.
It will be ready in a week's time (= one week from now).
She learnt to drive in three weeks (= after three weeks she could drive).
But other dictionaries distinguish "in" when to say when something will happen & when to say how long someone takes to do something
We use in to say how long it takes someone to do something:
He was such a clever musician. He could learn a song in about five minutes.
We use an apostrophe -s construction (in a year’s time, in two months’ time) to say when something will happen. We don’t use it to say how long someone takes to do something:
I won’t say goodbye because we’ll be seeing each other again in three days’ time. We can also say in three days, without time, in this example.
He ran the marathon in six hours and 20 minutes.