I am quite new to the python coding scene and is currently working on a code on Python using a ultrasonic sensor, I want to add the output value into a list (maintaining the list size)where the list is constantly updating with the latest value from the ultrasonic sensor basically OVERWRITTING the list in a sense,
I have seen examples of Append but they are from fix values,
>>> a = [1,2,3]
>>> b = [4,5,6]
>>> a + b
[1, 2, 3, 4, 5, 6]
is there anyway to append with the output from the ultrasonic sensor? Thank you very much
my_list=[100,50,10,20,30,50] #current list
#example of expected output
distance=300
distance=250
distance=230
my_list=[230,250,300,100,50,10]
# the latest 3 reading will be appended to the front of the list
# while still maintaining the size of my_list
Do let let me know if further clarification or information is needed, thank you in advance.