Python 3 Practice Question - Larger List

Hello Codecademy Community :wave:,

I’m having issues with this question in the Python 3 practice question:

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.

Here is the code I have written as a response:

#Write your function here
def larger_list(1st1, 1st2):
  if len(1st1) == len(1st2):
    return (1st1[-1])
  elif len(1st2) > len(1st1):
    return (lst2[-1])
    return (1st1[-1])

#Uncomment the line below when your function is done
print(larger_list([4, 10, 2, 5], [-10, 2, 5, 10]))

I’m continuing to receive this error message, but I’m not sure where I’ve gone wrong.

  File "", line 2
    def larger_list(1st1,1st2):
SyntaxError: invalid syntax

My code is not returning the print command. Please help me figure out this issue, I greatly appreciate your feedback! :grin:

variables in python can’t start with a number, you’ve got a 1 where you probably want a lower case L

Hope that helps

1 Like

Oh gosh, you are so right! This is why it’s important to copy+paste instead of writing things out yourself. Thank you :sparkling_heart:

1 Like