I am trying to run some code that will get data from a website(ques) and compare it to a CSV(ans) file to get a result.
def ans(ques):
ans = False
csvfile = open('database.csv', 'r')
reader = csv.reader(csvfile, delimiter=',')
for row in reader:
if ques == row[0]:
ans = row[1]
break
if ques == row[1]:
ans = row[0]
break
return(ans)
CSV file:
QUESTION,ANSWER
1+1=?,It's 2
When i run this code i get this:
UnicodeWarning: Unicode equal comparison failed to convert both arguments to
Unicode - interpreting them as being unequal
However when i remove the '
it works as expected. Any help?