
Stanley Nkosi
4,233 PointsIterating over Range -Task 1 of 1 How do you append my_list ? Stanley Nkosi
The body of the for loop should append the current value to the provided list called my_list.append(val)
my_list = []
for i in range(0,10,1):
my_list.append(val):
print(i)
4 Answers

Stanley Nkosi
4,233 PointsThank you Steve.

Steven Parker
205,345 PointsHere's a few hints:
- each line of the body of the loop must be indented more than the "for" line
- the "append" line should not end in a colon
- where does the "val" come from that you are appending? It's not defined in this code

Stanley Nkosi
4,233 PointsHi Steve, Thank you for the answer.I have indented the body.I have removed the semi-colon. Now,when I recheck it says,"Whoops it looks like my_list contains incorrect values or values are missing. The 'val' comes from the instruction that says,"To append a value to a list use syntax my_list.append(val).

Steven Parker
205,345 PointsWhen I run it with the other fixes applied, I get: "Bummer: NameError: name 'val' is not defined".
The instruction example is intended to be generic, they are using the term "val" to represent the variable that will contain the value you want to append. You wouldn't use the actual term "val" unless you chose that as your loop variable name.

Stanley Nkosi
4,233 PointsHi Steve, I have removed "val". When I recheck,I get the bummer that says,"Whoops looks like my_list contains incorrect values or is missing values.

Steven Parker
205,345 PointsYou "removed" it? Did you put something in it's place? (Hint: what is it you want to append?).
If you're still having trouble, repost the whole code in the current state.
Steven Parker
205,345 PointsSteven Parker
205,345 PointsStanley Nkosi — normally you'd choose "best answer" on the answer that helped solve the question!