Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I insert EMPTY values in python's list?

Here, I have the list test_list=[1,2,3,0,5]
I want to change the list which contains empty values, like [1,2,3, ,5]

All the way I found is to add None or np.nan or just ”.

But all those values are not working at my case, cause I just need to leave the place empty. how can I create it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

(The reason I need it is to put those values into scipy’s interpolation. If there’s any know-how or tips, I will be glad to hear that)

>Solution :

Umm.. maybe yes. I just need the list which will be printed as [1, 2, 3, ,5] in this format…

You can define a class with a repr() of the empty string:

>>> class Nothing:
...     def __repr__(self):
...             return ''
... 
>>> l = [1, 2, 3, Nothing(), 5]
>>> l
[1, 2, 3, , 5]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading