floors = [1, 2, 5, 4, 2] result = 0 for i in range(len(floors)-1): distance = abs(floors[i] - floors[i+1]) result += distance print(result)
To embed this project on your website, copy the following code and paste it into your website's HTML: