There are numerous ways to keep yourself motivated.
Then you come into a situation where you feel like giving up it is important to imagine yourself 10 years down the line and let that be your motivation to keep on going and work towards that. Stay disciplined to work towards your goal and always tell yourself that you can get through anything if you just put your mind to it.