Hi guys, i did solve these two problems myself without googling.
I have little confusion on nested loops here:
def exponents(bases, powers): new_list =  for i in range(len(bases)): for j in range(len(powers)): new_list.append(bases[i] ** powers[j]) return new_list print(exponents([2,3,4],[1,2,3]))
def larger_sum(lst1, lst2): sum1 = 0 sum2 = 0 for i in range(len(lst1)): sum1 += lst1[i] for j in range(len(lst2)): sum2 += lst2[j] if sum1 > sum2: return lst1 elif sum1 == sum2: return lst1 else: return lst2 print(larger_sum([1, 9, 5], [2, 3, 7]))
In the second code, i was not getting the solution due to using of nested loops, I have little doubts that, in the second code too, there are two parameter lists. But , why don’t we use nested loop here, while in the 1st code, we used nested loop as I need to multiply the base index to the power index.
Somebody, please clear my doubts.
I will be very thankful to you.