0
Why is this outpout?
a = ["hello","little","dog"] a.append(a) print (a) outpout: ['hello' , 'little', 'dog' [...]]
4 Réponses
+ 2
To get the output you want use extend:
a.extend(a)
0
I expected this outpout ['hello', 'little', 'dog','hello', 'little', 'dog']
0
thanks
- 1
Since the list contains itself, the output would be infinite. In order to avoid that they replace the "nested" list by [...] (I'm guessing).