Instruction
Great, it's time to wrap things up!
A
forloop can be used with arange:for i in range(1, 6): ...
A
forloop can be used to iterate over a string:password = 'sfdj3@3d' for letter in password: ...
A
whileloop looks like this:while condition: ...
It executes as long as the condition is true.
Instead of
counter = counter + 1
you can simply usecounter += 1
- The
breakkeyword is used to terminate the whole loop. - The
continuekeyword is used to skip to the end of the current iteration. - Loops can be nested.
All right, how about a short quiz now?
Exercise
Click to continue.



