python 3.x - Removing second element of a list -


i working on code has list of integers such list1 = [1,2,3,4,5] , want print out 1 3 4 5 print out "new list" without second element.

you can use indexes slicing (i assume want keep original list intact):

>>> list1[0:1] + list1[2:] [1, 3, 4, 5] 

so in general skip i element (when 0 included):

>>> list1[0:i] + list1[i+1:] 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -