list-copy function using range() : range « Buildin Function « Python Tutorial






def f(mylist, data):
    newlist = mylist[:]            # make a copy of mylist
    for i in range(len(mylist)):
        newlist[i] = mylist[i] + data
    return newlist








13.38.range
13.38.1.A built-in function to make ranges for you
13.38.2.The given end point is never part of the generated list
13.38.3.specify a different increment (even negative)
13.38.4.writes out the numbers from 1 to 100
13.38.5.uses the range() function to create a temporary sequence of integers the size of a list
13.38.6.Simple Counters based on range function
13.38.7.For each item in a range
13.38.8.List Comprehensions
13.38.9.select what to include in the new list
13.38.10.range(): range(start, end, step=1)
13.38.11.range(end), range(start, end)
13.38.12.mile/kilometer conversion
13.38.13.list-copy function using range()