i keep getting a typeerror on this code specifically in the last line .join(Q)
. can anyone help me with it?
Q=[]
a = Question.split()
for i in a:
if i in stop:
continue
else:
Q.append(1)
b = " ".join(Q)
i keep getting a typeerror on this code specifically in the last line .join(Q)
. can anyone help me with it?
Q=[]
a = Question.split()
for i in a:
if i in stop:
continue
else:
Q.append(1)
b = " ".join(Q)
Use str
in list comprehension like so:
b = " ".join([str(x) for x in Q])
Q
contains integers and to be passed to join()
it must contain strings. Use Q.append("1")
to append strings to the list.