why it prints None? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 4

why it prints None?

lista = [1,2,3,4,5,6] print(lista.extend([7,8]))

27th Dec 2018, 8:22 AM
sky
sky - avatar
2 Respostas
+ 10
print() is supposed to display the return value of the lista.extend() method. But there's nothing to return really, it just extends lista by the list [7, 8]. So the default return value, None, is printed. If you want to see how lista looks now, just print it after extending: lista.extend([7,8]) print(lista) Hope that helps šŸ˜Š
27th Dec 2018, 8:44 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 4
It Doesn't return anything, sice get a nonešŸ¤—
27th Dec 2018, 6:52 PM
Mr_Ā¢hitoā€¢Ā°ā€¢
Mr_Ā¢hitoā€¢Ā°ā€¢ - avatar