-
Notifications
You must be signed in to change notification settings - Fork 11
Loops
Jamiras edited this page Jun 26, 2020
·
1 revision
Loops allow for a section of code to be repeated - usually once for each value in a collection or range.
for key in dictionary { code }
Executes the specified code for each key in the provided dictionary.
for item in array { code }
Executes the specified code for each item in the provided array.
for index in range(start, stop, [step]) { code }
Executes the specified code for each integer in the inclusive range between start
and stop
. If step
is not specified, it's value is 1. range(1, 5)
is equivalent to [1,2,3,4,5]
and range(1, 5, 2)
is equivalent to [1,3,5]
.