1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

data structure Python push pop

Posted at
#データがの一番上に値を入れる:push(n)
#nは入れる値
#データの一番上から値を取り除く+表示する :pop()

push(5)
push(6)
pop()
>>6

#emptyからpop()しようとすると、'stuck underflow'エラーとなり、
上限以上にpush(n)しようとすると'stuck overflow'エラーとなる

push(7)
pop()
pop()
>>stuck underflow

#peekを使うと、削除せずに一番上から値を表示できる。
push(5)
peek()
>>5


1
1
1

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?