0

can someone please show to me how to loop through 3 different lists. My problem would be, let's say, I have

List1 = [1,3,4]
List2 = [3.2,1.5,3.3]
List3 = ['x','y','y']

using for loop, to loop through list3, I want to create a condition when IF an i in that list is 'y', I will multiply the indices of list1 and list2 (these indices must be the same as the index of list3) and then append the product to another list (let's say list4).

However, when the loop encounter 'x' it should pass (pass the indices of list 1 and 2 as well) and go to the next index of the list3.

in the end, I wanna get the sum of the list4, as my final output.

I'm very new in python, can someone please help me with this? this is just a part of my big project, and I've already done the huge chunk of it, however, this one's very challenging for me. would really appreciate your help. thank you very much

  • I have trouble following your explanation. Can you show an example of what you're trying to do with these lists? –  Aug 23 '18 at 13:31
  • apology for not showing an example, in the above list, the values of index 0 for all 3 lists are, 1, 3.2 and 'x', since it is the value of the string is 'x', i will not multiply the list values 11 and 3.2. – newcodic2018 Aug 23 '18 at 20:33
  • in index 1 of these three lists, 3, 1.5 and 'y', the value of index 1-list3 is 'y', only then I need to multiply the index 1 of both list1 and list2 which is 3*1.5, and then store the product of this multiplication into a new list called list4. Then once done that, I'll keep continuing looping through the entire lists. Sorry, I hope this clear now, thank you sir. – newcodic2018 Aug 23 '18 at 20:37

0 Answers0