How can I append a None value to a list in Python?

salamey picture salamey · Apr 23, 2014 · Viewed 42.6k times · Source

I have a list :

A = ['Yes']

I want to have

A = ['Yes',None]

How can I do this?

Answer

sshashank124 picture sshashank124 · Apr 23, 2014

Just use append:

A.append(None)

>>> print A
['Yes', None]