Should we print inside of the loop?

Why does print have to be outside the while loop?

Because that is the intended last step of the program. It may be useful to print inside the loop to inspect each iteration’s effect on the list, but the final printing pretty well proves such inspection unnecessary, and all we want to see printed is the final result.