I don't know the difference between [None] and [] as the title says.
A=[None]
B=[]
A.append(1)
B.append(1)
for i in A:
print(i)
for i in B:
print(i)
by turning
None
1
1
Why is None being printed out? Aren't you adding 1 to the empty list for both? Please answer me.
python
[None]
is completely different from the empty list []
. You can think of it as a list that contains one object called None
.
>>> len([])
0
>>> len([None])
1
© 2025 OneMinuteCode. All rights reserved.