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

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -