Larger sum, challenge, python

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer!

Hello
When I try to solve the problem I am confused on indentation.

the question is like that " Create a function named `larger_sum()` that takes two lists of numbers as parameters named `lst1` and `lst2` .
The function should return the list whose elements sum to the greater number. If the sum of the elements of each list are equal, return `lst1` ."

I reckon when I didn’t apply indentation to under the “if condition” the answer was correct.
Otherwise, an error message came up like that `larger_sum([1, 9, 5], [2, 3, 11])` should have returned `[2, 3, 11]` , and it returned [1, 9, 5].’
Let me know why I do not have to apply indentation to under the “if condition”

you nested your `if`/`else` clauses within your second for loop

this means you are comparing the sum of list1 with only the first item of list2.

2 Likes