how do i add a constantly changing value to my list?

For every value, you can use my_list.insert(0, new_value) which will insert new value to 1st position. Your code will look something like:

    my_list.insert(0, new_distance) # add new value to beginning (0 index)
    my_list = my_list[:-1] # remove last element to keep the size same

You can also combine those, eg: my_list[:-1].insert(0, new_distance)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top