LoginSignup
1
1

【競プロ】Python 標準入力 リスト

Posted at

標準入力 *(アンパック演算子)

map関数のみだと

map関のみでint型のリストの入力を受け付けると

A = map(int,input().split()

#入力
1 2 4 5 6

#出力
<map object at 0x1024b4d00>

とmapオブジェクトが表示されてしまう。

リストで囲ってみても

A = [map(int,input().split()]

#入力
1 2 4 5 6

#出力
[<map object at 0x104669040>]

とmapオブジェクトをリストにしたものが出る。

しかし、アンパック演算子 * を使うと

A = [*map(int,input().split()]

#入力
1 2 4 5 6

#出力
[1, 2, 3, 4, 5, 6]

となる。

1
1
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
1
1