import numpy as nm
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=a[k-1]
a.sort()
for i in range(n):
if a[i]>=b:
x=i
break
n=n-x
print(n)
import numpy as nm
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=a[k-1]
a.sort()
for i in range(n):
if a[i]>=b:
x=i
break
n=n-x
print(n)
hey @Shivam31 ,
Actually you are using map function to convert to integer , so the system doesn’t know how much inputs to actually it needed . Its just know that , whenever the input will break i need to split and store the values.
hence it requires an extra enter at the end to complete inputting the array .
I hope this would have resolved your doubt.
now my code is working, I have just erased that import numpy line and everything else is the same. And please tell my way to get input in a single line for n int.
For that you need to make a for loop to take n inputs. Then , only you can be able to save those values in an numpy array .
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.