+ 2
I tried with a topic of lists
num=[7,7,7,7,7] num[2]=num print(num) ....as ouput I got [7,7,[...],7,7] ..can anyone plz explain reason for [...] This
5 ответов
+ 2
Priya You're welcome.
+ 3
You created a self-referencing list...
Edit. Try to print num[2], num[2][2], num[2][2][2]....
+ 3
Priya It isn't giving output as [7,7,[7,7,7,7,7],7,7] because everytime the element at index 2 is the list itself.
it would look something like
[7,7,[7,7,[7,7,[7,7,[7,7,[.......],7,7],7,7],7,7],7,7],7,7]
if you want to see it with variable name
it would be
num = [7,7,num,7,7]
where num is again [7,7,num,7,7]
and this continues.
You can say it is infinite.
It will be a self referencing list as Mihai Apostol said.
+ 2
Why it isn't giving output as [7,7,[7,7,7,7,7],7,7] ?????????
+ 2
Thanks a lot both of u to clear my doubt