python - How to specify a position in a list and use it? -


Is there any way that I can give a status in a list, eg 2 for the third value, and then use that position directly, like list.remove [2]?

For example:

Say my list,

  test = [0,1,2,3,2,2,3]   

Is there any way, if the user wants to delete the 5th value, which is between 2, then you can give only one position and use it directly. In this case, If I want to use the exam (2) It will remove the first 2 visible from the list, so one such method is that I can say the status of mid 2 and then the rest list

some test.remove [ 2] would be a good idea to implement, [] value in position.

You can use:

  & gt; & Gt; & Gt; Test = [0,1,2,3,2,2,3] & gt; & Gt; & Gt; Test.pop (5) # removes the item and returns it as 2; Gt; & Gt; & Gt; Test [0, 1, 2, 3, 2, 3]  

or:

  & gt; & Gt; & Gt; Test = [0,1,2,3,2,2,3] & gt; & Gt; & Gt; Dell Test [5] #remodes only items & gt; & Gt; & Gt; Test [0, 1, 2, 3, 2, 3]  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -