私の解答
a, b, n = map(int, input().split())
li = [int(x) for x in input().split()]
for i in range(n):
if li[i] == a:
li[i] = b
print(li[i])
else:
print(li[i])
解答例1
values = input().split()
A = int(values[0])
B = int(values[1])
N = int(values[2])
a = [0] * N
values = input().split()
for i in range(N):
a[i] = int(values[i])
for i, ele in enumerate(a):
if ele == A:
a[i] = B
for ele in a:
print(ele)
解答例2
A, B, N = map(int, input().split())
a = [int(x) for x in input().split()]
for i, ele in enumerate(a):
if ele == A:
a[i] = B
for ele in a:
print(ele)