Dec-17-2020, 07:02 PM
Thank you for all the input. First of all, I am learning Python from scratch and can't use any of the functions such as product, etc. I need to do it with what I have learned thus far.
1. I agree, the second loop is not necessary. I went through it and debugged.
The reason I added the other loop is because I didn't truly understand that the sum_list had already taken care of it.
Here is the new code. I adjusted it according to "bowlofred" without the "product" function. What does this function do anyway?
1. I agree, the second loop is not necessary. I went through it and debugged.
The reason I added the other loop is because I didn't truly understand that the sum_list had already taken care of it.
Here is the new code. I adjusted it according to "bowlofred" without the "product" function. What does this function do anyway?
list1 = [30, 50, 110, 40, 15, 75] list2 = [10, 60, 20, 50, 80] sum_list = [(n1, n2) for n1 in list1 for n2 in list2 if n1 + n2 > 100] for index, value in sum_list: print(index, value) OUTPUT: 30 80 50 60 50 80 110 10 110 60 110 20 110 50 110 80 40 80 75 60 75 50 75 80