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 Sequences Sequence Iteration Iterating over Ranges


ONCE AGAIN i am being asked to do something i am not sure how to do. It was not covered in the video and now i need to do some extra stuff like 'append(val)' whatever that means.

my_list = []
for i in my_list.append(val):
Tim Oltman
Tim Oltman
7,714 Points

Hi Rigby,

First, you want to iterate over a range. The video Iterating with Ranges covers this.

Second, you have to deal with this append stuff. Luckily, you don't have to do anything fancier than just use the code they gave you.

What really helped me when going these courses was to really slow down, pause the videos, and play around with the examples in the workspace as I went. Anything that the instructor does in the video you should type out in the workspace to see how it works. Change some of the values and see what happens.

Then, with the Challenges, the biggest thing is to follow the directions precisely. Break it down into steps, and try it out in the workspace before submitting your answer.

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 67,779 Points

It is the val reference that is causing the

# in evaluating the statement 
for i in my_list.append(val):

# The reference
# is evaluated first

Even if val was defined, the append method does not return a value so the for loop would not run. The correct form would be:

for i in my_list:

Post back if you need more help. Good luck!!!