Basically, I want to make an algorithm that apply a function to each element in my list.
database = ['A', 'B', 'A', 'B', 'C']
And I have a function named Weighting.
def weighting(speed, time):
return (speed * time)
I want to apply this function to each element of the array so,
mylist[0] = speed * time
mylist[1] = speed * time
mylist[2] = speed * time
etc..
And for each element, they have different speeds and time.
Then, I want to display the new array where each elements have been calculated based on the function weighting.
So far i did:
def weight(speed, time):
return_list = []
for x in return_list:
x = speed * time
return return_list
def run():
database = ['A', 'B', 'A', 'B', 'C']
I am new to python, so could someone help me?