Assuming you already tried and you cannot think of a way because you are new to programming.
First you can think how it is done by hand then try to see what you learned in the class. Loop will help to repeat and if statements to take decisions. Every language will have this basic blocks which helps you to do anything programmatically. Python does not have a “do while loop” like other languages, which make sense because its redundant.
Try to think of your own come up with the answer it will help you to learn.