11/18 - list manipulation in functions


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/lists-and-functions/exercises/list-manipulation-in-functions?action=lesson_resume&link_content_target=interstitial_lesson

<In what way does your code behave incorrectly? Include ALL error messages.>
This is throwing an error, but is also apparently the solution?
The error is:

 File "python", line 3
    def list_extender(1st):
                      ^
SyntaxError: invalid syntax

<What do you expect to happen instead?>
No error and should run and return the list 3, 5, 7, 9

```python

My code:

n = [3, 5, 7]
# Add your function here
def list_extender(1st):
  1st.append(9)
  return 1st
print list_extender(n)
<do not remove the three backticks above>

#2

Try changing the numeral 1 to the letter l. Python variables cannot start with a number.


#3

That did it, thanks! I thought the “l” was a “1”

I think it’s funny the tutorial told the student to avoid “l” and “1” precisely for this reason…


#4

Yeah, I often harp when seeing someone use the letter l for a variable name on account of it being easily mistaken. Fortunately it’s not a mistake we make more than once or twice.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.