I want to calculate the percentage change either increase or decrease in a list. here is my list ages = [20.3, 30.5, 20.3, 45.5, 50.6, 29.5, 13.4, 140.9]
here is my code
def percent_change_in_naira(value):
try:
for i in value:
if old_num > new_num:
((((old_num-new_num)/old_num)*100))
elif old_num == new_num:
0
else:
((((new_num-old_num)/old_num)*100))
return value
except ZeroDivisionError:
return 0
How do assign 'new_num' to a new number on the list above and 'old_num' to a previous number on the list above?
Thanks in advance