>>> L = [123, 'spam', 1.23] >>> len(L) 3 >>> L[0] # インデクシング 123 >>> L[:-1] # スライシング [123, 'spam'] >>> L + [4,5,6] # 連結で新しいリストを作る [123, 'spam', 1.23, 4, 5, 6] >>> L # 元のリストは変更されない [123, 'spam', 1.23] # 末尾に要素を追加してリストを長くする >>> L.append('NI') >>> L [123, 'spam', 1.23, 'NI'] >>> L.pop(2) # 途中の要素を削除する 1.23 >>> L # (del L[2]でも同じことが出来る) [123, 'spam', 'NI'] >>> M = ['bb', 'aa', 'cc'] >>> M.sort() >>> M ['aa', 'bb', 'cc'] >>> M.reverse() >>> M ['cc', 'bb', 'aa'] >>> L [123, 'spam', 'NI'] >>> L[99] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range >>> L[99] = 1 Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list assignment index out of range