0

Code:

l1 = eval(input("Enter the elements"))
l2 = []
l3 = []
l = len(l1)
l2.extend(l1[0:l//2])
l3.extend(l1[l//2:l+1] 
print(l2)
print(l3)
print(l3.extend(l2))

Output:

Enter the elements[1,2,3,4,5,6,7,8]
[1, 2, 3, 4]
[5, 6, 7, 8]
None

Please tell why the code is showing None as the output

MartinSGill
  • 1,044
  • 12
  • 16

1 Answers1

0

the extend method doesn't return a value, here is a simple example:

print([1].extend([2]))

output:

None 

if you want to print the value after you apply the extend method you should first extend your list then print your list:

l3.extend(l2)
print(l3)
kederrac
  • 15,932
  • 5
  • 29
  • 52