LoginSignup
0
1

More than 5 years have passed since last update.

python3x: print functionで使えるend argment

Posted at

python3ではprint関数は(おそらく)print(arg, end='\n') と定義されている。これは引数がアウトプットされた後に丁寧に改行してくれるように。ただそれをいじってあげることができる。簡単な例で言えば、

def value(l):
    for items in l:
        print(items, end=' ')

>>> val = value([el for el in range(1,11)]) #1 2 3 4 5 6 7 8 9 10
#endが指定されていないと
>>> print([el for el in range(1,11)]) 
1
2
3
4
5
6
7
8
9
10
# 改行されて表示される
0
1
1

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