How can I ignore ValueError when I try to remove an element from a list?

前端 未结 7 947
遇见更好的自我
遇见更好的自我 2021-02-03 17:19

How can I ignore the \"not in list\" error message if I call a.remove(x) when x is not present in list a?

This is my situation:

7条回答
  •  南笙
    南笙 (楼主)
    2021-02-03 17:46

    you have typed wrong input. syntax: list.remove(x)

    and x is the element of your list. in remove parenthesis ENTER what already have in your list. ex: a.remove(2)

    i have entered 2 because it has in list. I hape this data help you.

提交回复
热议问题