As Oscar Lopez and others have already explained, an extension is a command that returns None to perform a command / request split.
They all suggested fixing it, using the extension as a team, as intended. But there is an alternative: use the query instead:
>>> var = [0] + range(1, 10)
It is important to understand the difference here. extend modifies your [0] , turning it into [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] . But the + operator leaves only [0] and returns a new list [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] .
In cases where you have other links to the list and you want to change all of them, you obviously need to extend .
However, in cases where you simply use [0] as the value, using + not only allows you to write compact, fluid code (as you tried), but also avoids mutating values. This means that the same code works if you use immutable values ββ(like tuples) instead of lists, but more importantly, it is crucial for a functional programming style that avoids side effects. (There are many reasons why this style is useful, but one of the obvious is that immutable objects and functions without side effects are inherently thread safe.)
abarnert
source share