I am supposed to write a function for one of my computer science classes in python. The function is supposed to take in a startValue and then increment it until numberOfValues is reached. This is my function so far:
def nextNValues(startValue, increment, numberOfValues):
result = int(0)
for i in range(0, numberOfValues):
increase = i * increment
result = startValue + increase
return result
I call it by doing:
print(nextNValues(5,4,3))
The problem is that the output is only 13. How do I make it so it returns a number each time it increments. For example, 5, 9, 13? I have been having this problem with my previous functions but I have just been adding and removing things without much logic to get it to work. What am I doing wrong?
printthe values inside of the function?