# Passing a range into a function

#1

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

#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.

#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.

#4

Because the instructions wanted you to return a list containing, `[0, 2, 4]`

#5

if the list changes number can be change?

#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]`

#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.

#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`

#9

could u tell me weather my explanation is wright or wrong.

#10

Yes, it is.

#11

Thank you. I wish you happy new year.

#12

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