Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how can i get the n values by space separated with condition in python

T = int(input())
for x in range(T):
    N = int(input())
    num = [int(i) for i in input().split() if int(i) == 1 or int(i) == -1][:N]
    
    if len(num)==N:
        print(1)
    else:
        pass
    
    
 
PREVIOUS NEXT
Tagged: #values #space #separated #condition #python
ADD COMMENT
Topic
Name
6+2 =