Help me explain this code plzzz | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help me explain this code plzzz

a = [] a.append(a) print(a) #Output: [[...]]

9th Jul 2021, 6:05 AM
TCorn
TCorn - avatar
3 Answers
+ 5
Here's some info on the python built-in constant 'ellipsis'. Read through it. Especially the part about circular references!! https://python.land/python-ellipsis
9th Jul 2021, 6:30 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Why do you want to append a to a? Use a = [] a.append(value to append to list) print (a) a = [] a.append(5) print (a) #output [5]
9th Jul 2021, 6:16 AM
Sudo
Sudo - avatar
0
Basically the code should append “a” into the list with variable name “a” i.e a=[“a”]. So when you print(a) you get [“a”]. But the code may not work, because you did not put a in quote. i.e you used a.append(a) instead of a.append(“a”)
10th Jul 2021, 10:20 PM
Gideon Okike
Gideon Okike - avatar