Python Forum
Multiply Lists of Lists
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiply Lists of Lists
#2
taking two lists of equal length:
>>> list1 = [0.74, 0.91, 1.22, 0.91, 1.07, 1.07, 1.07, 1.07, 1.07, 0.74, 0.91, 0.91, 1.07, 1.07, 0.91, 1.07]
>>> list2 = [1.23, 0.97, 2.09, 0.97, 0.83, 0.83, 0.83, 1.23, 0.83, 0.83, 0.83, 0.83, 0.83, 0.83, 0.83, 0.83]
>>> result = [l1 * l2 for l1, l2 in zip(list1, list2)]
>>> print(result)
[0.9102, 0.8827, 2.5498, 0.8827, 0.8881, 0.8881, 0.8881, 1.3161, 0.8881, 0.6142, 0.7553, 0.7553, 0.8881, 0.8881, 0.7553, 0.8881]
Reply


Messages In This Thread
Multiply Lists of Lists - by klatlap - May-29-2022, 12:39 AM
RE: Multiply Lists of Lists - by Larz60+ - May-29-2022, 07:21 AM
RE: Multiply Lists of Lists - by klatlap - May-29-2022, 03:03 PM
RE: Multiply Lists of Lists - by paul18fr - May-29-2022, 05:20 PM
RE: Multiply Lists of Lists - by Pedroski55 - Jun-06-2022, 10:24 PM
RE: Multiply Lists of Lists - by Gribouillis - Jun-07-2022, 05:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turn list of arrays into an array of lists Cola_Reb 6 1,778 Jul-20-2022, 06:55 PM
Last Post: Cola_Reb
  Array lists vs Linked Lists sabe 2 1,814 Nov-28-2020, 12:31 AM
Last Post: perfringo
  Creating new lists with names depending on a changing integer in a while loop l_butler 0 1,602 May-24-2020, 04:05 PM
Last Post: l_butler
  Formula with elements of list - If-condition regarding the lists elements lewielewis 2 2,829 May-08-2020, 01:41 PM
Last Post: nnk
  Compare two lists. Count larger values dervast 2 2,902 Dec-11-2019, 11:39 AM
Last Post: perfringo
  sorting 2D lists by column ToffieFaye 8 115,384 Sep-25-2019, 07:30 AM
Last Post: ToffieFaye
  How to work with large lists without crashing Python? Corate 8 14,529 Mar-14-2018, 09:41 PM
Last Post: wavic
  Argument lists sobrio1 7 4,240 Oct-16-2017, 01:54 AM
Last Post: ichabod801
  Calculate the mean of an array across dimension with lists of different length rakhmadiev 2 4,580 Aug-01-2017, 02:52 AM
Last Post: Larz60+
  Are lists Python's name for "variable array" Luke_Drillbrain 6 5,027 Apr-21-2017, 09:14 AM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020