I have a list of code to update the value of time for each 5 elements. This is the code:
msg = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
theta=1
time=4.5
def get_new_theta(msg, theta,time):
new_theta = [theta]
new_time = [time]
for a, b in zip(msg[3::5], msg[4::5]):
new_theta.append(new_theta[-1] + a + b)
new_time.append(new_time[-1]+time)
return new_theta
return new_time
for i, theta in enumerate(get_new_theta(msg, theta,time)[:-1]):
for j in range(5):
print(theta, msg[i*5+j],time)
However, I did not get the desired output. The desired output should be:
1 1 4.5
1 2 4.5
1 3 4.5
1 4 4.5
1 5 4.5
10 6 9
10 7 9
10 8 9
10 9 9
10 10 9
29 11 13.5
29 12 13.5
29 13 13.5
29 14 13.5
29 15 13.5
Need help from this forum. Thank you.
return new_theta, new_time