So I'm currently working in similarities and after making index.html to be able to see which functions work, I started working in lines. When passing in this function with the compare1 (1).c and compare2 (2).c files I get the error:
TypeError: decoding to str: need a bytes-like object, list found
I researched what was the problem and tried ASCII encoding my list but it didn't work. Here is my code:
from nltk.tokenize import sent_tokenize
def lines(a, b): #Return lines in both a and b
list_a = a.splitlines()
list_b = b.splitlines()
final_list = []
for x in list_a:
if x in list_b:
if x not in final_list:
final_list.append(x)
return [final_list]
and here is my code when I tried ASCII encoding:
from nltk.tokenize import sent_tokenize
def lines(a, b): #Return lines in both a and b
list_a = a.splitlines()
list_b = b.splitlines()
final_list = []
for x in list_a:
if x in list_b:
if x not in final_list:
final_list.append(x)
for x in final_list:
x = x.encode("ASCII"):
return [final_list]
Any ideas as to why this happens and how to fix it? All help is appreciated.