This line,
labels = ["{0}-{1}".format(i, i + 9) for i in range(0, 100, 10)]
is equivalent to this code:
labels = []
for i in range(0, 100, 10):
labels.append("{0}-{1}".format(i, i + 9))
Let's test it out:
labels = ["{0}-{1}".format(i, i + 9) for i in range(0, 100, 10)]
another_list = []
for i in range(0, 100, 10):
another_list.append("{0}-{1}".format(i, i + 9))
print(labels == another_list)
# True
It's called List Comprehension.
Also, you have range(0, 100, 10)
: range
is "an immutable sequence of numbers."
You can see the numbers like this:
In [1]: list(range(0, 100, 10))
Out[1]: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]