I am having trouble figuring out the code for this program, i am trying to read into the csv file and loop through, then display all the ratings above 8.0 (the csv file is a list of movies with ratings next to them) here is my code:
import csv
def getInputs():
f=open("IMDB films.csv")
csvFile = csv.reader(f)
#Create empty arrays
tittle=[]
rating=[]
#Loop through each row in file
for row in csvFile:
#add each item from each row to each array
tittle.append(row[0])
rating.append(row[1])
if rating >("8.0"):
print(tittle, rating)
f.close() #close the file
getInputs()
Everytime i try to run the IF statement it just comes up with the error of: TypeError: '>' not supported between instances of 'list' and 'str'
Would really appreciate any help with this as i am struggling with it, Thank you.
Aucun commentaire:
Enregistrer un commentaire