Python Forum
Need help with List of Lists
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with List of Lists
#6
Sure,just use a separate index:

list_a = [-1, 2, -2, 3, 41, 38, 22, 10, -1, 3]
list_b = [40, 30, 20, 10]
 
e_len = len(list_a) - len(list_b) + 1
 
for a_idx in range(e_len):
    elist = []
    b_idx = 0
    for bval in list_b:
        elist.append(list_a[a_idx + b_idx]*bval)
        b_idx += 1
    print(elist)
Reply


Messages In This Thread
Need help with List of Lists - by johnissa - Apr-21-2018, 01:23 AM
RE: Need help with List of Lists - by Larz60+ - Apr-21-2018, 03:50 AM
RE: Need help with List of Lists - by johnissa - Apr-21-2018, 04:11 AM
RE: Need help with List of Lists - by Larz60+ - Apr-21-2018, 05:10 AM
RE: Need help with List of Lists - by johnissa - Apr-21-2018, 05:35 AM
RE: Need help with List of Lists - by Larz60+ - Apr-21-2018, 05:45 AM
RE: Need help with List of Lists - by johnissa - Apr-21-2018, 07:24 AM
RE: Need help with List of Lists - by Larz60+ - Apr-21-2018, 09:47 AM
RE: Need help with List of Lists - by pyghorz - Apr-22-2018, 04:09 PM
RE: Need help with List of Lists - by Larz60+ - Apr-22-2018, 04:31 PM
RE: Need help with List of Lists - by pyghorz - Apr-22-2018, 04:38 PM
RE: Need help with List of Lists - by Larz60+ - Apr-22-2018, 06:11 PM
RE: Need help with List of Lists - by ljmetzger - Apr-22-2018, 06:24 PM
RE: Need help with List of Lists - by Larz60+ - Apr-22-2018, 09:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Check if a list exists in given list of lists Daniel94 2 3,018 Apr-07-2020, 04:54 PM
Last Post: deanhystad
  List of lists manipulation Stahlios 5 5,321 Apr-18-2018, 07:43 PM
Last Post: Stahlios
  List of lists MarkLogan 3 100,794 Feb-28-2018, 11:21 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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