I wanted to learn how to program but with which laptop and what should it cost.
That is your decision.
What do you want to program?
I would make sure that the computer has 8GB RAM, then even a cheap laptop would have to cope with server-side frameworks. If you want to develop games, you need a computer that can run the games. It is also strong enough to develop it.
I program on a T60 for 100 EURO
Goes with any old used device, unless you are messing around with games.
In principle, you can program on a Raspberry Pi. Accordingly, it works on every 199 euro laptop. Depending on what you program, more cores or more RAM can be an advantage. I personally also like to have a large monitor, programming on an 11 or 13 inch notebook is quite annoying