Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Collections (Retired) Lists Redux Manipulating Lists

Ron Kopald
Ron Kopald
785 Points

Lists redux 3/3 challenge Error, code works in workspace

Hi, when I run this code I get the message that there are elements missing from my list but when I run this in the python workspace console, I get a list with the numbers 1:20 What am I missing?

lists.py
the_list = ["a", 2, 3, 1, False, [1, 2, 3]]

# Your code goes below here
the_list.pop()
the_list.insert(0, the_list.pop(3))
the_list.remove(False)
del the_list[1]
the_list.extend(range(3,21))

3 Answers

Ron Kopald
Ron Kopald
785 Points

Thanks, guys for your help! I was a little fuzzy on the range function, and how it indexes. Details!
Also, Kenneth I am having no luck with the preview tab. It never seems to show any output.

Mikael Enarsson
Mikael Enarsson
7,056 Points

The problem is that range([start value inclusive], [stop value exclusive], [step]. So, if you run range(1, 5) you get [1, 2, 3, 4]. With your code, you get [1, 2, 3, 3, 4, 5, ..., 20].

I hope this helps ^^

Ron Kopald
Ron Kopald
785 Points

[1,2,3,4,5, ....., 20 ] is exactly what I want, and it is what I get, but the site will not accept this as being correct even though it lists the correct values of 1:20 after using the .extend function.

Mikael Enarsson
Mikael Enarsson
7,056 Points

Are you certain that you don't get two 3's?

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Check the Preview tab and see what you have.