Sometimes, while working with Python list we can have a problem in which we have to compare two lists for index similarity and hence can have a task of mutiplication equal index pairs. Let’s discuss certain way in which this task can be performed.
Method #1 : Using loop +
This task can be performed by passing the zip(), which performs task of mapping both list with each other, to the function which computes the product according to equal indices.
The original list 1 is : [5, 6, 10, 4, 7, 1, 19] The original list 2 is : [6, 6, 10, 3, 7, 10, 19] Multiplication of Identical elements : 7980
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python - Retain K match index values from other list
- Python | Get match indices
- Python | Pandas Series.str.match()
- Python | Substring Key match in dictionary
- Python | Prefix key match in dictionary
- Python - Test rear digit match in all list elements
- Python - Match Kth number digit in list elements
- Python - Number of positions where Substrings Match of Length K
- Python | re.search() vs re.match()
- Regular Expressions in Python - Set 2 (Search, Match and Find All)
- Mahotas - Match template to image exactly
- Python | Record Index Product
- Python - Product of elements using Index list
- Python - Row Summation of Like Index Product
- Dunn index and DB index - Cluster Validity indices | Set 1
- Python | Print list after removing element at given index
- Python | Get the Index of first element greater than K
- Python | Replace elements in second list with index of same element in first list
- Python | Multiply each element in a sublist by its index
- Python | Handling no element found in index()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.