Why is this outpout? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why is this outpout?

a = ["hello","little","dog"] a.append(a) print (a) outpout: ['hello' , 'little', 'dog' [...]]

4th Apr 2017, 1:08 PM
Shredder
Shredder - avatar
4 Answers
+ 2
To get the output you want use extend: a.extend(a)
4th Apr 2017, 1:43 PM
Igor B
Igor B - avatar
0
I expected this outpout ['hello', 'little', 'dog','hello', 'little', 'dog']
4th Apr 2017, 1:15 PM
Shredder
Shredder - avatar
0
thanks
4th Apr 2017, 1:47 PM
Shredder
Shredder - avatar
- 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).
4th Apr 2017, 1:15 PM
Luca Garrera