Name: Anonymous 2010-10-28 16:16
I am trying to write a program using a for or while loop that takes in two lists ([10,20,30,40] and [0,0,1,2]) for instance and the values of the second list are supposed to be the indexes of the first list that are supposed to be doubled
output: [40, 40, 60, 40]
the original string isn't supposed to be changed
does anyone have any suggestions? I've gotten:
def double(A,B):
i = 0
a = []
while i < len(B):
a = A[B[i]] * 2
i += 1
return A
output: [40, 40, 60, 40]
the original string isn't supposed to be changed
does anyone have any suggestions? I've gotten:
def double(A,B):
i = 0
a = []
while i < len(B):
a = A[B[i]] * 2
i += 1
return A