This is a very basic thing. You should use a while loop, and learn what is a shift register. Do not use the "Run Continuos" mode.
If you are a student, you can have access to the Core 1 online training videos. I strongly suggest you to start learning using these freely available sources, before asking here to solve your home work 😉