list in python behaviour -
I have a list that lists my_list Now I want to add an integer to 4 from the third list in my_list When I print My_list, I see that integer 4 has been added to each list in my_list. there is one Just the way to add 4 to the third list? Expected: Actual: Find Answers move in xrange (5)] mylist = [[]] * 5
my_list [2] .append (4)
& gt; & Gt; & Gt; My_list = [[]] * 5
& gt; & Gt; & Gt; My_list [2] .append (4)
& gt; & Gt; & Gt; My_list
[[4], [4], [4], [4], [4]]
[[], [], [4], [], []]
[[4] ], [4], [4], [4], [4]]
my_list = [[]] I should do the
Comments
Post a Comment