Skip to content

Instantly share code, notes, and snippets.

@JohnsonLuu
Created June 2, 2020 15:43
Show Gist options
  • Save JohnsonLuu/e15167e2cf1a0f804e20ade807e40292 to your computer and use it in GitHub Desktop.
Save JohnsonLuu/e15167e2cf1a0f804e20ade807e40292 to your computer and use it in GitHub Desktop.
"""
Write a function named larger_list that has two parameters named lst1 and lst2.
The function should return the last element of the list that contains more elements. If both lists are the same size, then return the last element of lst1.
"""
#Write your function here
def larger_list(lst1, lst2):
if(len(lst1) >= len(lst2)):
return lst1[-1]
else:
return lst2[-1]
#Uncomment the line below when your function is done
print(larger_list([4, 10, 2, 5], [-10, 2, 5, 10]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment