+ 1

Can each list value divided by some number ?

Want to add 3rd section in table with factor by 2nd section of data value https://code.sololearn.com/cWFxhezLD1w1/?ref=app

20th Mar 2020, 6:13 AM
ғᴜɴ 3x
ғᴜɴ 3x - avatar
12 ответов
+ 2
ғᴜɴ 3x Yes there is a way. original = [1,2,3,4,5] newlst = [] for i in original: newlst.append(i/2) #i/anything print(newlst) another, shorter way. a = [1,2,3,4,5] c = [i/2 for i in a] print(c)
20th Mar 2020, 6:31 AM
maf
maf - avatar
+ 6
Additionally we have the map function. c = list(map(lambda x:x/2), a)
20th Mar 2020, 6:44 AM
Oma Falk
Oma Falk - avatar
+ 6
can u tell us more about the program?
20th Mar 2020, 7:03 AM
Oma Falk
Oma Falk - avatar
+ 5
maf not clear for me too.
20th Mar 2020, 6:57 AM
Oma Falk
Oma Falk - avatar
+ 2
strength = [i/22.5 for i in load] Did u encounter a problem?
20th Mar 2020, 6:50 AM
maf
maf - avatar
+ 1
maf It works but i shuffle that list so result is mixed up https://ibb.co/v11t4nb I want strenth by dividing value of load by 22.5
20th Mar 2020, 6:48 AM
ғᴜɴ 3x
ғᴜɴ 3x - avatar
+ 1
Oma Falk help him bro i can't solve the problem :D Idk why the answer is different, sorry
20th Mar 2020, 6:56 AM
maf
maf - avatar
+ 1
Thank you both solved <3 I want another section for average the 3 values in strenth
20th Mar 2020, 7:01 AM
ғᴜɴ 3x
ғᴜɴ 3x - avatar
+ 1
ғᴜɴ 3x np. This wouldn't be a list so, avg = sum(strength) / len(strength)
20th Mar 2020, 7:03 AM
maf
maf - avatar
+ 1
maf letme try this
20th Mar 2020, 7:07 AM
ғᴜɴ 3x
ғᴜɴ 3x - avatar
+ 1
Oma Falk I want to make a report card for personal use Which have random values in each
20th Mar 2020, 7:08 AM
ғᴜɴ 3x
ғᴜɴ 3x - avatar
0
+--------+------+--------------------+ | weight | load | strenth | +--------+------+--------------------+ | 8.99 | 545 | 21.24444 | | 8.66 | 485 | 21.288888 | | 8.88 | 491 | 21.333332 | +--------+------+--------------------+ Here i want 545/22.5 = strenth 24.22 not random amswer
20th Mar 2020, 6:54 AM
ғᴜɴ 3x
ғᴜɴ 3x - avatar