Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+3 votes

hi, having trouble getting my double list to output in question 5.

So far i have, doubleList = [] above my for loop and i get the correct number of list elements, but not the correct numbers are outputting. any hints?

asked in CSC201 Spring 2021 by (1 point)

4 Answers

+5 votes
 
Best answer

I recommend checking the latest PowerPoint that Dr. Stonedahl posted on Moodle about how to modify the index inside of the list.

You can use the for loop to go through each index of the list and multiply it by 2. The indexes in that list will be changed without creating any variable.

answered by (1 point)
selected by
+3 votes

Making a new list does not work here- the problrm asks you to modify the existing list. You can access the individual pieces of a list with []. You will need to set up a loop to modify each item.

answered by (1 point)
+3 votes

after the for loop, have original list equals the new list. Something like this,
aList[0:] = doubleList

answered by (1 point)
+2 votes

Use for loop and slicing to refer to each number in the list. Next, write a line multiplying by the number to multiplied. Make sure you redefine the position in the list itself.

answered by (1 point)
...