using the function range to loop over indices sometimes we do not have listbut want to repeat the same operation given number of times if we know the number of repetitions this task is an obvious candidate for for loopbut for loops in python always iterate over an existing list (or list-like objectthe solution is to use built-in python function named rangewhich returns list of integers for in range( + ) ( + / )** print( ,ahere we used range with single argument which will generate list of integers from zero to (not including we can also use range with two or three arguments the most general case range(startstopincgenerates list of integers startstart+incstart+ *incand so on up tobut not includingstop when used with just single argumentas abovethis argument is treated as the stop valueand range(stopis short for range( stop with two argumentsthe interpretation is range(start,stop)short for range(start,stop, this behaviorwhere single function can be used with different numbers of argumentsis common both in python and many other programming languagesand makes the use of such functions very flexible and efficient if we want the most common behaviorwe need only provide single argument and the others are automatically set to default valueshoweverif we want something differentwe can do so easily by including more arguments we will use the range function in combination with for loops extensively through this bookand it is good idea to spend some time becoming familiar with it good way to gain feel for how the range-function works is to test statements such as print(list(range(start,stop,inc))in an interactive python shellfor different argument values filling list with values using for loop one motivation for introducing lists is to conveniently store sequence of numbers as single variablefor instancefor processing later in the program howeverin the code abovewe did not really utilize thissince all we did was print the numbers to the screenand the only list we created was simple sequence from zero to it could be more useful to store the amounts in listwhich can be easily be achieved with for loop the following code illustrates very common way to fill lists with values in python in python range does not technically produce listbut list-like object called an iterator in terms of use in for loopwhich is the most common use of rangethere is no practical difference between list and an iterator howeverif we tryfor instanceprint(range( )the output does not look like list to obtain output that looks like listwhich can be useful for debuggingthe iterator must be converted to an actual listprint(list(range( ))