+ 1
What is the result of this???????
nums=list(range (5)) Print (mums[4]) /*. The answer is 4 why ???? */
3 odpowiedzi
+ 4
Nums = [0,1,2,3,4]
Nums[0] = 0
Nums[1] = 1
Nums[2] = 2
Nums[3] = 3
Nums[4] = 4
Never forget: indexing starts at 0 unless stated otherwise.
Hope this helps 😃😃
+ 2
range is a generator function and looks something like this:
def range(n):
i = 0
while(i<n):
yield i # yield keyword gives new number every time
i += 1
take look at my code for your reference
https://code.sololearn.com/c799w4wspvRZ