It seems that the methods for putting data in the array were messed up, so make a note of it.
List
.append(data)
Add data to the end. Same as push.
.insert(index,data)
Insert data at the index position. Note that ** index value does not cause an error even if it exceeds the length of the array, and it seems to be put at the end as it is **, so be careful.
hoge = list([1,2,3])
hoge.insert(1,4) # 1,4,2,3
hoge.insert(5000,5) # 1,4,2,3,5
Set
.add(data)
Add data. ** It seems that the order will be sorted automatically. ** **
hoge = set([1,2,3])
hoge.add(0) # 0,1,2,3
hoge.add(4) # 0,1,2,3,4
Recommended Posts