Lesson 7: Lists in Python

posted Dec 1, 2017, 8:05 AM by Attila Lengyel
series = []

series.append(0)
series.append(1)
series.append(1)
series.append(2)
series.append(3)

print("Sequence:",series)
print("Length:", len(series))
print("4th item:", series[3])

last = series[len(series)-1]
print("Last item:", last)

onebefore = series[len(series)-2]
print("Before last:", onebefore)

series.append(last + onebefore)

print("Sequence:",series)
Comments