# Some tests are not passed

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!

I​nput

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.

O​utput

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))
``````

Hello, @evggen, and welcome to the Python Forum!

Unfortunately, no one seems to have noticed this post until now. Sorry we didn’t get to you sooner.

It is a good idea to test for a variety of cases. This applies to many types of problems. Atypical cases often go unnoticed. Check whether Ivan is placed properly in line under each of the following conditions:

• Ivan is shorter than some already on line, and taller than others.
• Ivan is the same height as one other person on line.
• Ivan is the same height as more than one other person on line.
• Ivan is shorter than everyone else on line.
• Ivan is taller than everyone else on line.
• Ivan arrives when no one else is on line.

What should be done if Ivan is the first one to arrive? Since the line would have been empty, he should become first in line. However, if he is greeted with an empty line, we get a message similar to this:

``````Traceback (most recent call last):
File "/Users/quercus/Documents/get_in_line.py", line 3, in <module>
L = [int(i) for i in L]
File "/Users/quercus/Documents/get_in_line.py", line 3, in <listcomp>
L = [int(i) for i in L]
ValueError: invalid literal for int() with base 10: ''
``````

If you check the contents of `L` when Ivan arrives first, you’ll see why that message occurs.

Since with any line, someone inevitably arrives first, we need to accommodate that person. Please take this into account with a revision to the code, and let us know how it works out. We will be happy to help.

EDITED on November 27, 2021 to provide suggestions regarding specific cases to accommodate.