-2

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)

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153

2 Answers2

0

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.

Michael Bianconi
  • 5,072
  • 1
  • 10
  • 25
0

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.

A.N.Tanvir
  • 76
  • 3