indexed assignment in list

Peter Otten __peter__ at web.de
Wed Jul 11 03:00:51 EDT 2018


Peter Otten wrote:

> a = [[1]] * 7
> 
> creates a list containing seven references to the same inner list [1].

I. e. it is roughly equivalent to

b = [1]
a = [b, b, b, b, b, b, b] 





More information about the Python-list mailing list