How to remove an element from a list by index

后端 未结 18 2946
闹比i
闹比i 2020-11-22 03:22

How do I remove an element from a list by index in Python?

I found the list.remove method, but say I want to remove the last element, how do I do this?

18条回答
  •  青春惊慌失措
    2020-11-22 04:02

    Generally, I am using the following method:

    >>> myList = [10,20,30,40,50]
    >>> rmovIndxNo = 3
    >>> del myList[rmovIndxNo]
    >>> myList
    [10, 20, 30, 50]
    

提交回复
热议问题