0
0

配列の要素の入れ替え Python3編

Posted at

私が書いたのはこれ

A,B,N = map(int,input().split())
S = list(map(int,input().split()))
for i in range(len(S)):
    if i + 1== A:
        tmp = S[B-1]
        S[B-1] = S[A-1]
        S[A-1] = tmp
        break

for i in S:
    print(i)

でもよく考えたら、
べつにif文なくてもそのまま変えたらいいだけだった。。。
答え見てわかってしまったorz

0
0
2

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