Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python last non-zero value in a list

>>> import numpy as np
>>> np.max(np.nonzero([-2, -2, 0, 0, 0, 0, 0]))
1 # at index 1
>>> np.max(np.nonzero([-2, 20, -1, 0, 3, 0, 0]))
4 # at index 4
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #list
ADD COMMENT
Topic
Name
1+3 =