0
0

(D->C)2 * 2 の出力

Last updated at Posted at 2023-11-14

今日の問題はこれ
https://paiza.jp/works/mondai/stdout_primer/stdout_primer__2dim_array_step1
・8,7,1,3を2*2の形で出力せよという問題

私は
偶数番目のときに改行、奇数番目のときに半スペと考えて下記の様に実装

N =[0,8,1,3]
for i in range(len(N)):
    if (i + 1) % 2 == 1:
        print(N[i],end=" ")
    else:
        print(N[i],end="\n")

ところが他にもあり
もっと簡単にできた

print("0 8¥n1 3")

うん、たしかにそうなんだよなぁ。。。
まあ数字4つだけだからな
まあ、それにしてもprint内でも改行コード使えるんやな

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