Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append a null into a list in python

Tags:

python

list

null

If I have a list:

ex_list = [x,y,z]

but I want to have

[x, y, z, ]

How do I do it? I tried:

ex_list.append(None) 

but that doesn't work.

like image 719
user1179317 Avatar asked Jun 20 '26 11:06

user1179317


1 Answers

The concept of null does not exist in Python. The closest related idea would be None, which can be appended just as you indicated:

ex_list.append(None)

which would result in

[x, y, z, None]
like image 121
Christian Avatar answered Jun 23 '26 00:06

Christian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!