append function problem?

John Machin sjmachin at lexicon.net
Fri Apr 28 00:06:39 EDT 2006


On 28/04/2006 1:49 PM, randomtalk at gmail.com wrote:
> hello, recently i tried to use list.append() function in seemingly
> logical ways, however, i cannot get it to work, here is the test code:
> 
>>>> seed = [2, 3, 4, 5]
>>>> next = 7
>>>> seed1 = seed.append(next)
>>>> seed1
>>>> print(str(seed1))
> None

(1) Try this:

print seed

(2) Read the documentation (especially the HEADING and the FIRST sentence):

http://docs.python.org/lib/typesseq-mutable.html

(3) Work your way through the Python Tutorial; here's the section on 
lists, which covers your problem:

http://docs.python.org/tut/node5.html#SECTION005140000000000000000

>>>> def test(lst):
> ... 	print(str(lst))
> ...
>>>> test(seed.append(next))
> None
> 
> I'm using Activestate python (latest) on win xp sp2..
> 
> I'm not sure why seed1 and the function doesn't recognize the list..

I'm not sure what "doesn't recognize the list" means.

> 
> If anyone can point out where i'm going wrong would be much
> appreciated!
> Thanks in advance!
> 



More information about the Python-list mailing list