0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

paizaラーニング「各行の要素数の出力 Python3編」

Posted at

私の解答

li = [[1],[2, 3],[4, 5, 6]]
for i in range(len(li)):
    print(len(li[i]))

解答例

li = [[1], [2, 3], [4, 5, 6]]
for ele_li in li:
    print(len(ele_li))
  • for ele_li in li: で変数 ele_li に変数 li の各要素が順に代入されます。
  • for ele_li in li: のループ処理内で、len 関数を用いて変数 ele_li の要素数を出力することで求められている出力ができます。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?