Am I eligible for CAP exempt

Hello , I was on a H1B from Dec 2013 to Jan 2017 . Then I went back to my home country and came back to US on an H1B in Sep 2017 . In Nov 2017 I had to change change my work location and hence applied for an amendment which went into RFE. In May 2018 I went back to my home country and got a F1 visa to pursue graduation. I left my job in my home country in June and came back to the United States on a F1 in August to pursue Masters. My employer revoked my H1B petition in August 2018 with the RFE still pending. I want to know will be cap exempt after graduation or i have to go into the lottery again.

You do not need to go through lottery again. You will be cap-exempt.