Search
 
SCRIPT & CODE EXAMPLE
 

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
    
    
Comment

PREVIOUS NEXT
Code Example
Python :: generating cross tables after clustering 
Python :: python4 
Python :: python project structure 
Python :: python store salt in csv 
Python :: time, date 
Python :: pandas funtctioin for i 
Python :: graph node structure 
Python :: dht22 micropython library 
Python :: find difference between two triangular numbers python 
Python :: pandas to_csv overwrite check 
Python :: matplotlib boxplot fill box with pattern 
Python :: python import a filename given as string 
Python :: change label in dataframe per condition 
Python :: lunarcalendar python 
Python :: Count occurrence of each term in dataframe except for NaN 
Python :: Open a web browser in Python 
Python :: image name validate using regex python 
Python :: odoo.py odoo 14 
Python :: def dict(d) 
Python :: give utton a number python 
Python :: python requests json backslash 
Python :: loaves 
Python :: how to convert variable in Python ? 
Python :: 12000000/12 
Python :: python sha256 crypt decrypt 
Python :: django BruteBuster error failed attempts 
Python :: Applies the f function to all Row of this DataFrame 
Python :: data wrangling python 
Python :: torch print floating precision 
Python :: knn example 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =