How to read an array of integers from single line of input in python3

前端 未结 4 764
情深已故
情深已故 2020-11-30 09:37

I want to read an array of integers from single line of input in python3. For example: Read this array to a variable/list

1 3 5 7 9

What I

4条回答
  •  心在旅途
    2020-11-30 09:49

    You can get a good reference from the following program

    # The following command can take n number of inputs 
    n,k=map(int, input().split(' '))
    a=list(map(int,input().split(' ')))
    count=0
    for each in a:
        if each >= a[k-1] and each !=0:
            count+=1
    print(count)
    

提交回复
热议问题