i'm programming a simple project for Guessing the next number in python ,in this part , i need to divide the last number of "raw","lst","age" list to the previous number only in each list ...
here is my example code
raw = [1,5,10]
lst = [2, 6 , 12]
age = [8 , 16 , 48]
therefore , i want to divide only The last two values and the output like that :
[2]
[2]
[3]
do you know any code , method or function for that? thanks
CodePudding user response:
Simply access the values over their indices:
result = l[-1] / l[-2] # replace 'l' with your list-variable(s)