11. List manipulation in functions


#1



It comes up with this error:

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


I don't see anything wrong with it. What is happening?


n = [3, 5, 7]
def list_extender(1st):
    1st.append(9)
    return 1st
print list_extender(n)


#2

Hello @dillsie,

Variable names in Python cannot start with a number, they must start with letters...


#3

@dillsie,

NOTE:

value of my_var should be a valid python variable name.
Which is

  • the uppercase and lowercase letters A through Z,
  • the underscore _ and,
  • except for the first character, the digits 0 through 9

( shortly use pattern /[a-z][a-z0-9_]*/i )_.


#4

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