Python3 List len()メソッド
説明
len() メソッドはリストの要素数を返します。
構文
len()メソッドの構文:
len(list)
パラメータ
- list -- 要素数を計算するリスト。
戻り値
リストの要素数を返します。
例
以下の例は len() 関数の使用方法を示しています:
例
#!/usr/bin/python3
list1 = ['Google', 'サンプル', 'Taobao']
print (len(list1))
list2=list(range(5)) # 0〜4 のリストを作成
print (len(list2))
list1 = ['Google', 'サンプル', 'Taobao']
print (len(list1))
list2=list(range(5)) # 0〜4 のリストを作成
print (len(list2))
上記の例の出力結果は以下のとおりです:
3 5その他の拡張
Python3 リスト