Why is it when you print a list it comes with the brackets?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why is it when you print a list it comes with the brackets??

lists

30th Dec 2018, 1:10 PM
௱ΛŁɪϦЦ
௱ΛŁɪϦЦ - avatar
4 Answers
+ 5
It's printed with brackets to indicate that it is a list. You can print it any way you like, for example like this: l = [1, 2, 3] print(*l, sep=', ') # output: 1, 2, 3 By the way, "list" shouldn't be used as a variable name as it is a python keyword.
30th Dec 2018, 1:30 PM
Anna
Anna - avatar
+ 2
Could you please specify the programmig language?
30th Dec 2018, 1:25 PM
Diego
Diego - avatar
+ 2
Thanks alot😊😊
30th Dec 2018, 1:31 PM
௱ΛŁɪϦЦ
௱ΛŁɪϦЦ - avatar
+ 1
python, but i guess it happens in every console language... say list =[0,1,2] print(list) the output will be [0,1,2] is there a way of printing without the brakets??
30th Dec 2018, 1:27 PM
௱ΛŁɪϦЦ
௱ΛŁɪϦЦ - avatar