0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

指定要素の挿入・削除 Python3編

Posted at

前にもやった内容の問題なのだが、
insertとpopとでちょっと違いがあるので注意
追加する要素番号と、削除する要素番号とでちょっと違いがある

N = int(input())
A = [int(input()) for _ in range(N)]
n,B = map(int,input().split())
A.insert(n,B)
print(*A,sep='\n')

N = int(input())
A = [int(input()) for _ in range(N)]
n = int(input())
A.pop(n-1)
print(*A,sep='\n')

0
0
0

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?