remove function in python

The remove() function is used to remove the first match of a value in the list. Syntax: list.remove(obj) obj is the object to be removed, the following is the specific application:

if __name__ == '__main__':
    li = ["123", "a", 45, "bcd", "a"]
    # remove函数移除掉满足条件的第一个元素
    li.remove("a")
    print(li)

 

Guess you like

Origin blog.csdn.net/qq_39445165/article/details/114992843