11/18: im not sure what i am doing wrong?


#1

to_21 = [(1,21)]

odds = to_21[1:22:2]

middle_third = to_21[8:14]


#2

since codeacademy uses python2.7 you can do this

to_21 =range(1,22)

odds = to_21[::2]

middle_third = to_21[7:14]

print to_21
print odds
print middle_third

#3

I came up with the same code but codecademy's complier said my range is off and gave me an error saying it was 1-20 and not 1-21, I just changed the range to (1,22) then it let me pass. It could be an index issue since indexes start off at 0 instead of 1.


#4
to_21 = range (1,22)
odds = to_21 [::2]
middle_third = to_21[7:14]
print to_21
print odds
print middle_third

#6

A post was split to a new topic: What am I missing here? - slicing