0
Some one explain this to me please
What is the different between the two answers in This code . https://code.sololearn.com/ctgUqYg0a3xe/?ref=app
12 Answers
+ 1
Abdollahi Mohammed python creates the same empty list and copies it n times(rows) in your 'ls'.
To better understand what is happening, try changing a single element in 'ls', you will see it gets reflected in all rows.
While in 'lst', they are n separate lists. Also, you can change n-1 in ur code to -1
For in depth explanation: refer python shallow copying and deep copying.
+ 1
Thank you very much for your explanation
0
This is a list not just printing
0
I solve the problem but l didn't get why the two answers are different
Read the question please
0
Line 20 and 21
0
Exactly but look at two answers
0
I use the two list in same way
But the output is different
I just want to know why