11/18 Problem


#1



Getting the error "Oops, try again. It looks like your list for odds is [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]] instead of [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]." How can I remove the second pair of brackets in my result? Is there an easier way to do this?


Replace this line with your code. 
to_21 = range(1,22)

odds = []

numbers = to_21[::2]

odds.append(numbers)

middle_third = []

numbers2 = to_21[8:14:1]

middle_third.append(numbers2)


#2

Okay, you could remove the double square brace by simplifying things down for the odds like this:

odds = to_21[::2]


print odds

And I observed that you will have the same scenario with middle_third. So, do this, also:

middle_third = to_21[8:14:1]


print middle_third

#3

Oh so you do not have to make a new list and append a value to it you can just make the list equal to_21[::2]


#4

Yes, exactly. That was just you creating an empty list and appending another list.

Let's say I tried "minifying" things down. :slight_smile:


#5

yep that seemed to work thank you!


#6

You're welcome.

Have fun coding! :slight_smile:


#7

i had to use to_21[7:14:1]
print middle_third
just saying


#8

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