8. Omitting Indices


#1



my_list = range(1, 10) # List of numbers 1 - 10

# Add your code below!
print my_list[0:11:2]

ERROR: Oops, try again. Make sure to omit the appropriate indices in your list slice. Check the Hint if you need help!


#2

The first exclusive index is 10, not 11. Modify your slice to reflect same and the error will go away.


#3

my_list = range(1, 10)
print my_list[0:10:2]

Changed my code to this and still received the same error message


#4

What are you expected to output?

>>> my_list = list(range(1, 10))
>>> print (my_list[0:10:2])
[1, 3, 5, 7, 9]
>>> my_list = list(range(0, 10))
>>> print (my_list[0:10:2])
[0, 2, 4, 6, 8]
>>>

#5

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