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 (2016, retired 2019) Lists Combining Lists

Hello, I am trying to figure out what I am doing wrong. Can somebody help? thnx :)

Finally, use the .insert() method to place the string "start" at the beginning of your best list.

(x) Bummer! Did you use .insert() to add an item to the front?

lists.py
best = [ 1, 2, 3 ]
best.extend( [ 4 ,5 ] )
best.insert( 1, "start" )

2 Answers

Dzumret Pelivani
Dzumret Pelivani
5,399 Points

Remember that lists use zero based index. It means you start counting from zero: 0, 1, 2, 3 and so on.

Example with list:

# list of three items
my_list = [1, 2, 3]

# print item at beginning of string at index 0
print(my_list[0])

# outputs the value of the first item in the list which in this case is number one
1

# print item at index of one
print(my_list[1])

# output is
2

Hope you get the point. And help to solve your error in the line

# 'one' is not the start index of the best list
best.insert(1, "start")

Thnx, basically, silly me, I already knew the answer, I had taken a break for a while, busy season. :)

Thank you, again, for your time.

:)

Chase Marchione
Chase Marchione
155,055 Points

Hi Adam,

The first item of a list is at the '0th' position (this is common in a lot of programming languages: zero tends to be the first index in a lot of data structures.)

Interestingly, it seems like Python's whitespace sensitivity is influencing the compiler for this statement, although the statements you wrote to pass the first two tasks work fine.

best.insert(0, "start")

Hope this helps!