自然数 H, W, A, B が与えられます。縦に H 行、横に W 行で計 H * W 個の (A, B) という形式で文字列を出力してください。ただし、横は | (半角スペース 2 つとバーティカルライン) 区切りで、縦は = で区切って出力してください。また、縦の文字列間で = を出力する際は、その上の行と文字数がそろうように出力します。また、A と B は 9 けたになるように半角スペースを数値の前(右詰め)に埋めて出力してください。
というpaiza様の問題集をPython3で実装しました。
実装したコードは下記です。
values = input().split()
H = int(values[0])
W = int(values[1])
A = int(values[2])
B = int(values[3])
for i in range(H):
for j in range(W):
print(f"({A:>9}, {B:>9})", end="")
if j == W - 1:
print()
else:
print(end=" | ")
if i < H - 1:
print("=" * (22 * W + 3 * (W - 1)))