LoginSignup
0
1

More than 3 years have passed since last update.

[python]リストの要素を並べて表示する方法

Last updated at Posted at 2020-09-21

・リストの要素を横に並べて表示する。

例1
L = [1, 2, 3, 4, 5]

print(*L)
1 2 3 4 5

※リストの値はintでもstrでも可能

例2

L=' '.join(L)
print(L)
1 2 3 4 5 #str

※リストの値はstrのみ

intの時は

L = map(str, L) #intからstrに変換
L=' '.join(L)
print(L)
1 2 3 4 5

・リストの要素を縦に並べて表示する。

[print(i) for i in L]
1
2
3
4
5

(競技用プログラミングの時に手間取ったため。)
(追加があれば追記します。)

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