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

Bummer: AssertionError: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] != 9 : Whoops, looks like my_list contains incorrect values or is

Little lost on appending the value

iterating_ranges.py
my_list = []
for my_list in range(10):
    print(my_list)
Daniel Adari
Daniel Adari
3,577 Points

As I understand from your question, you want to append the number from 0 to 9 (inclusive) to my_list.

my_list = []
for my_list in range(10):
    print(my_list)  # Here, you are printing the list before you appended any values.

My solution:

my_list = []  # Setting the list
for val in range(10):  # Iterating over the range. 
    my_list.append(val)  # Append 'val' to your list.

1 Answer

Steven Parker
Steven Parker
231,268 Points

The instructions gave you the code for adding to the list when they said "To append a value to a list, use the syntax my_list.append(val)." That example assumes that the list variable will be named "val", which would give you:

my_list = []
for val in range(10):
    my_list.append(val)

And you don't need to "print" anything for this challenge.