I have a list of lists for years and unemployment rates:
datalist= [[1947, 3.9], [1948, 3.8], [1949, 5.9], [1950, 5.3], [1951, 3.3],
[1952, 3.0], [1953, 2.9], [1954, 5.5], [1955, 4.4] . . .]
I am able to modify the year (adding 1 to it) via
def newYear(a):
newList = datalist[:]
for i in range(len(newList)):
newList[i][0] += 1
return newList
I'm looking to create a new list of lists with the year and percent change in the unemployment rate from the previous year. I tried adding b, a and c to the function, but I don't know how to make this work.
def newYear(a):
newList = datalist[:]
for i in range(len(newList)):
newList[i][0] += 1
b = newList[i + 1][1]
a = newList[i][1]
c = (b-a)/a * 100
return newList