Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (Retired) Lists Redux List creation/extension methods

I want my_list to have 1 as the last item.

with respect to the above question what the function call

1 Answer

Kent Åsvang
Kent Åsvang
18,823 Points

I'm not sure that I have understood the question correctly, it was a little bit diffuse. Anyhow, if I assume you wish to add something to a list and make it the last item, in that case you just have to .append() it. Like so :

my_list = ["something", "something else", "something other than else", "and so on"]



# Output : 
["something", "something else", "something other than else", "and so on", 1]

So the correct function call is ".append()".

I hope this helped. Good luck.

Tnx for lending help. It worked