前回につづいてこちらも。
https://paiza.jp/works/mondai/stdout_primer/stdout_primer__2dim_array_step2
入力された半スペで区切られている 9 個の数値を 3 行 3 列の形式で出力という形。
前と同じ解法でいけるのでこちらで。
tmp = input()
N = tmp.split()
for i in range(9):
if (i + 1) % 3 != 0:
print(N[i],end=" ")
else:
print(N[i],end="\n")
・Nにいれるところは
N = input().split()
とやると1行でできる
・他の方法として数値は普通にprintして、他の解法として半スペか改行をi番目ごとにprintするというのがある。下のようになる
(print()はそのままだと改行するから)
for i in range(9):
print(N[i])
if i % 3 == 2:
print()
else:
print(" ",end="")