I should compare the previous, actual and next values in a list. This lines of code here underneath doesn't fully works.
The results of the code are:
5 4 6
8 10 11
20 18 19
so I miss values like
9 8 10
and values like
8 10 11
are simply wrong.
What am I missing in the enumerate method?
list=[1,2,3,4,5,4,6,7,9,8,10,11,14,15,16,20,18,19]
for i,n in enumerate (list):
if (i + 1 < len( list ) and i - 1 >= 0):
a = str( list[i - 1] )
b = str( n )
c = str( list[i + 1] )
if a>b<c:
print (a,b,c)
a>b and b < cand why do you need to convert them from int to str?listbecause that makes them hide python's inbuiltlistclass