Clear specific index values from Python

Asked 2 years ago, Updated 2 years ago, 42 views

myList = [4,7,2,342,9,3] when it comes to myList.remove(3) Is there a remove function that can be used in this way?

list.remove(3) After doing that, the 3rd value was erased at the end, not the 3rd index.

list python

2022-09-21 17:21

1 Answers

mylist.pop(idx) It can be written with and the idx has a default value of -1. Therefore,


2022-09-21 17:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.