how to use If to compare a number with an interval in python? -


when compile python code below, not have output! .csv file include numbers. (80,100,50,40,250,300).

import csv open("duration.csv") f:  d1 = [row[0] row in csv.reader(f)]   x in d1:  if 0<= x <200:   print("0<=x<200") 

any solution??

the values rows read strings csv module. should convert x integer , apply formatting:

if 0 <= int(x) < 200:     print("0<={}<200".format(x)) 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -