But there are many types of repetition in Python, witch one should I use?
Here is a qwick guide with my recomendations.
WHILE:
While loops are used when there is a factor that whill be changin 'n' times and you want to stop when said factor changes, also if the user is in control of the loop, if the factor is proned to change you use a while loop. (Learn More about While loops).
examples:

while (x==0):
print("Hi")
x=int(input("stop?, 0=no 1=yes")
Another example.
FOR:

1 example.
RECURSION:
Recursion is used when a function will repeat inside itself, func-ception, it will till a certian answer is reached, this one is tricky because you need to build the fuction with recursion in mind.
My most recent WSQs have been using recursion, so why dont you check that out?.
No hay comentarios:
Publicar un comentario