import csv
with open("input.csv") as f:
d1 = [row[0] for row in csv.reader(f)]
for x in d1:
if 0<=int(x)<30:
print("0<=x<30".format(x))
elif 40<=int(x)<120:
print("40<=x<120")
My code is shown above, and I am trying to save the output in a .csv file. Is there any solution to send data from elif
to csv.writer
?
if
/elif
. You do not "send" data from theelif
statement. It is just a conditional statement and the code inside will be executed if the condition is fulfilled. The code inside the statement is no different than outside, so you do not have to "send" anything. – mwormser 17 hours ago