1

I want a list maxIndexList in which all elements are to be equal to 0 like this

            maxIndex = 0
            maxIndex2 = 0
            maxIndex3 = 0
            maxIndex4 = 0
            maxIndex5 = 0

But I want the number of elements to be the same as the number of elements of arrivalDistanceList

            a = 23 + 3
            b = 5
            step = 2
            arrivalDistanceList = [meanSpeed * i for i in range(a, a + b * step, step)]

Is this the right way to go about it?

            for i in range(len(arrivalDistanceList)):
            maxIndexList = [0] + i

1 Answers1

1

I'm new to python, but I think that you can do it by using

#assume that arrivalDistanceList=range(9)
arrivalDistanceList=range(9)
# define maxIndexList as a list 
maxIndexList=[]
# create new item in maxIndexList list containing the value 0
for i in range(len(arrivalDistanceList)):
      maxIndexList.append(0)

There is probably a more compact way to do it

Noureddine
  • 180
  • 1
  • 10