List slicing


#1


l = [i ** 2 for i in range(1, 11)]

Should be [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

print l[2:9:2]
"""why it is not printing from 4 ""'

Replace this line with your code.


#2

because lists start coutning at zero, 1 is at index zero, 4 is at index 1, and 9 is at index 2, which is start value of your list slicing, so it starts at 9


#3

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