writing number of inputs in a list smaller tha n its left number in python

Viewed 37

I have given number of tress, i need to find number of tress will affected by wind subjected to condition if heigth of tress to its left are smaller.

I mean I have input as l= 4 2 5 1 3 7 6

my output=3 namely 4,5,3

my sample code

l=[]
l=int(input('enter list 1:'))

for i in l:
if l[i]> l[i-1]:
    print(i) 

I have to find number of tress will be affected by wind if entries in list are assumed tress height.
I am new to programming, what will be good approach to this problem. Please help, thanks.

1 Answers

the input in this solution assumes you enter the numbers like this. 37892920

l=list(input('entter list 1:'))
l = list(map(int, l))

last_i =0
for count, i in enumerate(l):
    

    if last_i< i and count >0:

        print(i)
        
    last_i = i
Related