I have a list of a list, where I want to do 1/x for every element x.
I tried
[1/x for x in list]
How can I proceed? I tried multiplying as an example
[x*10 for x in list]
But this only increasing the number of rows by 10, and not multiplying the actual values. What am I doing wrong?
Data
[[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.098671875, 16.09259521484375, 24.296372680664064],
[8.049411010742187, 15.993977661132812, 24.147247314453125],
[7.6774951171875, 15.250462036132813, 23.08390319824219],
[7.450130615234375, 14.684713745117188, 22.35098876953125],
[6.54051025390625, 12.876199340820312, 19.765568237304688],
[5.39010986328125, 10.824963989257812, 16.51649169921875],
[4.979031677246094, 9.665416870117188, 14.883976440429688],
[4.6164859008789065, 8.65063751220703, 13.361966552734373],
[3.9221954345703125, 7.188418579101563, 11.591380615234375],
[3.4298834228515624, 6.534327087402344, 10.445729370117188],
[2.9979116821289065, 5.92670654296875, 9.218810424804687],
[2.7159127807617187, 5.452456359863281, 8.101337585449219],
[2.216434326171875, 4.654409942626954, 6.799687652587892],
[2.111146240234375, 4.231194915771484, 6.159953155517577],
[1.6629426574707031, 3.4381407165527342, 5.140887298583984],
[1.2951142883300781, 2.8314198303222655, 4.534166412353516],
[1.1690933990478516, 2.3221934509277347, 3.6382754516601565],
[1.1690933990478516, 2.1871324157714844, 3.230146026611328],
[0.8830496215820313, 1.901088638305664, 2.645755157470703],
[0.7231619262695312, 1.4308435058593751, 2.175510025024414],
[0.2225925636291504, 0.7668316841125488, 1.5114982032775877],
[0.2225925636291504, 0.4066648483276367, 0.9712825393676758],
[0.2225925636291504, 0.2225925636291504, 0.2225925636291504],
[0.2225925636291504, 0.2225925636291504, 0.2225925636291504],
[0.0, 0.0, 0.0]]
new = ([list(itertools.accumulate(x)) for x in old])numpy.cumsumcould have handled the job you used the list comprehension for, too.alistis a lists of lists, thenxin[x for x in alist]is itself a list.[1]*10replicates the list; it doesn't multiply (in the numeric sense).