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?

More than 5 years have passed since last update.

Python > list > delete last insertion > del somelist[-1] > somelist.pop() / help([].pop) を教えていただきました。

Last updated at Posted at 2017-02-07

@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic
(No. 1270 / 12833)

Let's undo that last insertion:

>>> del marxes[-1]

実装してみた。
http://ideone.com/yRBduB

TodoList = []
print(TodoList)

TodoList.append('Futon')
TodoList.append('Monitor desk')
TodoList.append('Internet')
TodoList.append('Electronic Line')
TodoList.append('Water Line')
TodoList.append('Gas Line')
TodoList.append('etc')

print(TodoList)

for loop in range(6):
	del TodoList[-1]
print(TodoList)
実行結果
Success	time: 0.01 memory: 9992 signal:0
[]
['Futon', 'Monitor desk', 'Internet', 'Electronic Line', 'Water Line', 'Gas Line', 'etc']
['Futon']

追加学習事項

@shiracamus さんのコメントにてpop()help([].pop)を教えていただきました。

情報感謝です。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?