List extend with a generator expression referencing the list itself
List extend with a generator expression referencing the list itself Question: Consider the code below: a = [1, 2] a.extend(x*2 for x in a) print(a) At first glance, it would seem (to the uninitiated) that the code will generate the following output: [1, 2, 2, 4] But it does NOT generate that output. In fact, …