i had got this code correct. But i did not under stand this range concept could any one explain in brief.

# Passing a range into a function

**dave.n**#2

The range() function is used to create lists that contain computational streams. Basically the range function iterates through lists, based on a `(start, stop, and , step)`

In that specific order.

**hchirasani**#3

kk. I under stand that. why we gave number '3' in print my_function(rang(3)). could u please explain me?

why cont we give another number.

**dave.n**#6

SInce you are multiplying each list item by 2 if you change the range fucntion's argument to lets say 5,

`[0, 2, 4, 6, 8]`

**hchirasani**#7

kk. i understand that number should be given according to list size.

for example:

i = [0. 1, 2, 9, 5]

0 1 2 3 4-------------------- indices

in list i contain 5 values. according to ur calculation, but as per rule we know that indices = 4. so now we have to give 5 in print my_function(range(5)). am i correct.

**dave.n**#8

When working withe range() function if you give the range() function an argument that it is too small or too large it will return this error,`IndexError: list index out of range`

**system**#12

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.