Reply To: Python for-Loop

Welcome to Python Land Forums The Python Tutorial Python for-Loop Reply To: Python for-Loop

Erik van Baaren

OK sorry for the late reply. What you want is a range:


for i in range(1, 11):

This will give the output you are looking for. The range() function is an iterable, more about that can be read here:

Alternatively, you can use a list of numbers. Something like for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:.

But the example I gave you used a string, and with the for loop you iterate over the letters. Python sees those as strings, not as numbers.