+ 1
Why output is different for both scenario?
Scenario 1 arr = [[]]*3 arr[0].append(7) print(arr) Scenario 2 arr1=[[],[],[]] arr1[0]=7 print(arr1)
3 Réponses
+ 6
sc1: arr is an arr if three identical arrays (memory address is equal)
sc2 arr is an array of three different arrays
+ 5
list is array
+ 1
what if it is list?