Jim, Thank you, that was what I needed: now I can use one single list of 5- tuples and update only once!
Claude. On Mar 29, 2:46 pm, Jim Ragsdale <jimragsdal...@gmail.com> wrote: > you might try using the zip command. If you use the * operator with zip it > will unpack the elements into the individual variables > Sys, Dia, Pulse =zip(*mesures) > mesures.append([181,88,58]) > Sys[-1],Dia[-1],Pulse[-1] > > of course you can use zip to go the other way too: > mesures = zip(Sys, Dia, Pulse) > > On Sat, Mar 26, 2011 at 5:32 AM, clodemil <ollie...@scarlet.be> wrote: > > Hi All, > > > Measurements are taken for blood pressure and entered as 3-tuples: > > [P_systolic,P_diastolic,Pulse_rate] and put in a list > > > mesures=[[172,91,57],[181,88,58],[146,88,56],[191,85,59],[171,92,50], > > [157,93,55],[180,84,48],[142,77,60],[169,80,45],[162,76,59], > > [167,104,73],[166,81,53],[145,78,59],[163,98,58],[192,90,50], > > [184,85,60],[151,77,56]] > > > Various elements or the whole tuple are then used for diverse > > calculations and yet again output in lists. > > A new measurement entails updating ALL lists individually. So the idea > > is to make it automatic using accessory variables x and y and extract > > elements thereof. > > > mesures=[[172,91,57],[181,88,58],[146,88,56],[191,85,59],[171,92,50], > > [157,93,55],[180,84,48],[142,77,60],[169,80,45],[162,76,59], > > [167,104,73],[166,81,53],[145,78,59],[163,98,58],[192,90,50], > > [184,85,60],[151,77,56]] > > # [[P systolic,P diastolic,Pulse rate]] > > temps=[1,18,24,28,49,87,101,108,113,116,122,133,156,161,166,170,180] # > > Hours > > Sys=[172,181,146,191,171,157,180,142,169,162,167,166,145,163,192,184,151] > > Dia=[91,88,88,85,92,93,84,77,80,76,104,81,78,98,90,85,77] > > Pulse=[57,58,56,59,50,55,48,60,45,59,73,53,59,58,50,60,77] > > control=[len(temps),len(Sys),len(Dia),len(Pulse)] #all should be equal > > > x=[[185,82,57]] #new value to be appended to mesures > > y=185 #new value to be appended to temps > > > mesures=mesures+x #appending new value > > temps=temps + [y] #appending new value > > Sys=Sys + [x[0][0]] #appending new value > > Dia + [x[0][1]] #appending new value > > Pulse + [x[0][2]] #appending new value > > print control > > print(mesures) > > print temps > > print Sys > > > JOY: It works > > > DISAPPOINTMENT: It works ONLY if I call the lists on their own and NOT > > if they are called inside another cell: > > they then appear in the original unappended form: > > > for i,j in enumerate(temps): > > for k,l in enumerate(mesures): > > for m,n in enumerate(heuresF): > > if m==k: > > if i==k: > > print "Mesure n°",i,l,n > > > What am I doing wrong ? > > > TIA. > > > Claude > > > -- > > To post to this group, send email to sage-support@googlegroups.com > > To unsubscribe from this group, send email to > > sage-support+unsubscr...@googlegroups.com > > For more options, visit this group at > >http://groups.google.com/group/sage-support > > URL:http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org