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 trialRandall Brewster
5,041 PointsNow, make the_list contain only the numbers 1 through 20 by using .extend().
please help im stuck
the_list = ["a", 2, 3, 1, False, [1, 2, 3]]
# Your code goes below here
a_list = the_list.pop(3)
the_list.insert(0,a_list)
for item in list(the_list):
if isinstance(item, (str, bool, list)):
the_list.remove(item)
1 Answer
Joshua Ferdaszewski
12,716 Points- A note about your code:
list(the_list)
is redundant.the_list
is already a python list so there is no need to call thelist()
function on it. You can simplify this line to be justfor item in the_list:
- At the end of your script,
the_list
should be [1, 2, 3]. You need to add 4-20 to the list. I would recommend looking up therange()
function and then think about how you can combine it withthe_list
using the.extend()
method.
Good luck learning Python!