Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created July 28, 2020 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/7555b8affebd947143057b77f0fe98ed to your computer and use it in GitHub Desktop.
Save codecademydev/7555b8affebd947143057b77f0fe98ed to your computer and use it in GitHub Desktop.
Codecademy export
#Write your function here
def larger_sum(lst1: list, lst2: list) -> list:
"""
takes two lists of numbers as parameters named
lst1 and lst2
returns the list whose elements sum to the
greater number.
If the sum of the elements of each list are
equal, returns lst1
"""
return [lst1, lst2][-max((sum(lst1), 0), (sum(lst2), -1))[1]]
assert larger_sum([1, 9, 5], [2, 3, 7]) == [1, 9, 5]
#Uncomment the line below when your function is done
print(larger_sum([1, 9, 5], [2, 3, 10]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment