When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!
I’m having trouble with lists! I have written the code exactly* as in the solution(I think) but I cant for the life of me figure out why my code doesnt work, and the code, using the solution, does.
here is my code:
n = [3, 5, 7]
for i in range(0, len(x)):
x[i] = x[i]*2
It doubles the first item in the list(item 0) but all the other items retain their old value; as to why, I havent been able to figure that out. I’m sure its something simple that im missing but regardless I would like to understand what is wrong with my code.
I’m also recieving the following error message at the bottom of the editor when I run the program:
double_list([0, 1]) returned [0, 1] instead of [0, 2]; as I dont know exactly what it means or why its happening, I require your insights!
If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!