Here is my code:
list_b=[1,2,3,4,5,6,7,8,9,10]
print (list_b)
if(1 in list_b):
t=list_b.append('hello')
print(t)
else:
t1=list_b.append(100)
print(t1)
In the console it is showing me None
. (Image)
Here is my code:
list_b=[1,2,3,4,5,6,7,8,9,10]
print (list_b)
if(1 in list_b):
t=list_b.append('hello')
print(t)
else:
t1=list_b.append(100)
print(t1)
In the console it is showing me None
. (Image)
You haven't stated the issue, but I'm assuming it's this:
t=list_b.append('hello')
append()
modifies the array, it doesn't return a new array.
append()
method does not return any value but updates existing list.
if you want to see the updated list, use print(list_b)
.
print(t)
or print(t1)
will return None
as they don't have any return values.