you can say:
I learnt to drive in four weeks.
This means that it took you four weeks to become proficient in driving.
You can also say:
I learnt to drive for four weeks.
The meaning is slightly different to other sentence above. It means that you spent four weeks learning to drive but you did not necessarily become proficient at driving