As a new Python learner I request for information on how the loops work.
You could start with The Python Tutorial — Python 3.11.3 documentation
Then if you need more focused tutorials try web searches like these:
python while loop tutorial python for loop tutorial
If you get stuck please ask for some mentoring here.