Meet i, the Counter ๐ข
That little i in your loop isn't just decoration โ it's a variable, and
Python fills it with a different number every turn:
for i in range(5):
print(i)
That prints:
0
1
2
3
4
Two surprises there! Python starts counting at 0, not 1. And range(5)
stops before 5, so you get five numbers: 0, 1, 2, 3, 4.
The magic happens when you use i inside an f-string:
for i in range(11):
print(f"7 x {i} = {7 * i}")
An entire times table in two lines. Try doing that with a pencil. โ๏ธ
Your mission
- Make a variable
tableand store your favourite number in it - Use a
forloop withrange(11)soicounts 0 through 10 - Use an f-string to print a line for each one, like
8 x 3 = 24
Your code
Press โถ Run to see what your code does!