<jupyter_start><jupyter_text>list型オブジェクトの生成<jupyter_code>l = []
type(l), l
l = [0, 1, 2, None, "5"]
type(l), l
l = list("Beautiful")
type(l), l
l = list((0, 1, 2))
type(l), l<jupyter_output><empty_output><jupyter_text>list 型の算術<jupyter_code>[0] + [1]
l = [0]
l = l + [1]
l
l = [0]
l += [1]
l
[0] * 4<jupyter_output><empty_output><jupyter_text>list の関数<jupyter_code>l = [0]
l
l.append(1)
l
l.extend([2])
l
e = l.pop()
e
l
l.remove(0)
l
l.remove(0)
l.index(1)
# !pip install see
from see import see
see(l)<jupyter_output><empty_output><jupyter_text>list のシークエンス型としての利用  [ ] による要素へのアクセス<jupyter_code>weeks = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
weeks
len(weeks)
weeks[0]
weeks[-1]
weeks[:5]<jupyter_output><empty_output><jupyter_text>for による要素へのアクセス<jupyter_code>for day in weeks:
    print(day)<jupyter_output>Mon
Tue
Wed
Thu
Fri
Sat
Sun<jupyter_text>list のミュータブル性の確認<jupyter_code>l = [0, 1, 2, None, "5"]
l[3] = 4
l
print(id(l), l)
l += [6]
print(id(l), l)
print(id(l), l)
l = l + [7]
print(id(l), l)<jupyter_output>139659788592944 [0, 1, 2, 4, '5', 6]
139658836055856 [0, 1, 2, 4, '5', 6, 7]<jupyter_text>list のネスト（list の要素がミュータブルの時）と参照<jupyter_code>l = [[0, 1], [2, 3]]
l[0][1]
l = [[0]] * 4
l
l[0][0] = 1
l
l = [[0], [0], [0], [0]]
l
l[0][0] = 1
l
l = [0] * 4
l
l[0] = 1
l<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup