Appending to a list


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/0/3?curriculum_id=4f89dab3d788890003000096#


Oops, try again. Did you remember to append the number 4 to the end of your list?


n = [1, 3, 5]
n = n.append(4)# Append the number 4 here

print n

is anybody could tell me what's wrong with my code please?


#2

the append method will add the element to your list in memory. No need to assign that action to n. When you do that you override the value of n to None since the append operation does not return anything.


#3

Got it!! Thanks!!!!!!!!!!!!!!!!!!!!!!


#4

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