I have a following list:-
a = [1, 2, 3, 4]
From this list, I wanted to exclude the third item. How can i do this in python3
.
For example in R, if a was a vector then, I can do the following:-
a <- c(1, 2, 3, 4)
a[-3]
But I can't seem to find how I can do this in python.
Edit: I don't want to delete the item. For example, if I used the following:-
del a[2]
That would actually remove the second element. Hence, if I did print(a)
, only three numbers would be printed.
What I want to know is how to exclude the third element but not delete it. Like in the R
's example I have provided, it does not deletes the element, but rather excludes it. If in that example I did a[-3]
, only three items will be printed. But that does not meant the third item was deleted from the list.