Python – Handling Empty Values in a Python List

listpython

Is it possible to assign a list with empty values in Python?
This is possible:

x = []

But I want to do something like:

x = [4,7,2, ,8,9,1]

with an empty value inside.
The reason is that I have a large number of lists with 7 values and sometimes one of the values are unavailable. I need to keep say 8 as x[4],9 as x[5] etc.

My thoughts:
Maybe I should just put a number like 999 inside, or a string "empty" and tell my code to ignore 999 or "empty" or whatever.

What is the best option here?

Best Answer

Use None for the "empty" value.

a = [1,2,3,4,5]
b = [11,22,None,44,55]
Related Question