Python memo (for myself): Array

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.

Example:
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. ** **

Example:
hoge = set([1,2,3])

hoge.add(0)    # 0,1,2,3
hoge.add(4)    # 0,1,2,3,4

Recommended Posts

Python memo (for myself): Array
python [for myself]
heroku memo (for myself)
Python Tkinter notes (for myself)
Python code memo for yourself
Python memo
python memo
Python memo
python memo
Python memo
python memo (for myself): About the development environment virtualenv
Python memo
Python memo
2016-10-30 else for Python3> for:
python beginner memo (9.2-10)
Memo to ask for KPI with python
python beginner memo (9.1)
Python multidimensional array
[Beginner] Python array
★ Memo ★ Python Iroha
[Python] EDA memo
Python 3 operator memo
AtCoder cheat sheet in python (for myself)
Python array basics
[My memo] python
Python3 metaclass memo
[Python] Basemap memo
[Competitive programming] [Python3] Required knowledge, for myself
Python beginner memo (2)
[Python] Numpy memo
Memo # 4 for Python beginners to read "Detailed Python Grammar"
Memo # 3 for Python beginners to read "Detailed Python Grammar"
Memo # 1 for Python beginners to read "Detailed Python Grammar"
Memo # 2 for Python beginners to read "Detailed Python Grammar"
Summary of frequently used Python arrays (for myself)
Memo # 7 for Python beginners to read "Detailed Python Grammar"
A memo for creating a python environment by a beginner
Memo # 6 for Python beginners to read "Detailed Python Grammar"
Memo for editing scenes with Blender python (W.I.P.)
Memo # 5 for Python beginners to read "Detailed Python Grammar"
About Python for loops
Python class (Python learning memo ⑦)
My python environment memo
python openCV installation (memo)
Python module (Python learning memo ④)
Python basics ② for statement
Visualization memo by Python
[For memo] Linux Part 2
Python test package memo
[Python] Memo about functions
About Python, for ~ (range)
python regular expression memo
Binary search (python2.7) memo
python numpy array calculation
[My memo] python -v / python -V
python textbook for beginners
Python3 List / dictionary memo
[Memo] Python3 list sort
Python Tips (my memo)
Refactoring tools for Python
[Python] Memo about errors