i had got this code correct. But i did not under stand this range concept could any one explain in brief.
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.
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.
Because the instructions wanted you to return a list containing,
[0, 2, 4]
if the list changes number can be change?
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]
kk. i understand that number should be given according to list size.
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.
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
could u tell me weather my explanation is wright or wrong.
Yes, it is.
Thank you. I wish you happy new year.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.