- 2

How?

I don’t understand the last question in ‘range’

15th Jan 2018, 10:19 AM
Jesse3021
2 Antworten
+ 2
By which, I assume, due to lack of information, you are referring to the last question in the Python course entitled "range". For any curious souls, the question is as follows: What is the output of this code? nums = list(range(3, 15, 3)) print(nums[2]) Essentially, the first line gets an iterator in the range of 3 to 15 (exclusive) with a step of 3, and converts it to a list. So, nums looks like this: [3, 6, 9, 12] So, you want to find the element with the index 2, which is essentially the third element, which happens to be 9. If you have any more questions, please feel free to ask.
15th Jan 2018, 11:05 AM
blackcat1111
blackcat1111 - avatar
0
Thanks blackcat1111, that really helped
15th Jan 2018, 11:07 AM
Jesse3021