I’m solving such task.
Ivan decided to enroll in a swimming course. Before the start of the lesson, swimmers line up in height from highest to lowest. Ivan needs to determine his place in the line. Help him do it!
The program reads as input a non-increasing sequence of natural numbers entered from the keyboard. Each number is a height of a person in the line. Then, the number X is entered, which is the Ivan’s height. All numbers are positive integers which do not exceed 200. It is assumed that a user inputs data properly, so the program does not need to check whether the input is correct.
Print the number under which Ivan should stand in a line. If there are people in the line with the same height as Ivan’s, then he must stand after them.
I get warnings that in 2 cases my code doesn’t work and I can’t find where can be mistake.
s = input() L = s.split(sep=' ') L = [int(i) for i in L] x = int(input()) for i in range(len(L)): if L[i] < x: L.insert(i, x) print(i+1) break elif i == len(L) - 1: L.append(x) print(len(L))