24 lines
884 B
Python
24 lines
884 B
Python
# we're going to do more than just give an exploration of for loops we're also going to
|
|
# talk a lot about lists, dictionaries, and the general ways that for loops allow us to traverse
|
|
# different kinds of data
|
|
|
|
# okay so the very first thing here is our basic for loop
|
|
|
|
for i in range(10):
|
|
print(f"Oh look we're counting: {i}") # note that we're using the format strings, f-strings, here
|
|
|
|
# and in general whenever you need to do something a certain number of times you're going to be
|
|
# using a for loop.
|
|
|
|
# range lets us pick out a, well, range for the numbers
|
|
|
|
for i in range(5,17):
|
|
print(f"We're counting again: {i}")
|
|
|
|
|
|
# okay but one of the cool things about for loops is that they can operate over anything
|
|
# that's like a list or a sequence, anything that has an order to it
|
|
|
|
# lists? I guess we should talk about those a little more formally here
|
|
# essentially a list
|