# I am getting a Type Error in this Line

Diff = [i - j for i,j in zip(text_features, author_signature)]


Diff is a List , text_features = [1, 2, 3] , author_signature = [3, 2, 1]

You must be getting a type error because the elements of text_features and/or author_signatures are not able to be subtracted in the part i - j.

Depending on what they are, you could try converting them. For example, you could try making one or both of them numbers or strings like this:

Diff = [float(i) - float(j) for i,j in zip(text_features, author_signature)]   # both made into numbers

Diff = [str(i) - str(j) for i,j in zip(text_features, author_signature)]   # both made into strings (words)


To give better advice, you need to give an example of what your two lists are that are in the zip()

## EDIT

Based on the update in the question, I see that it works as expected for me:

In [1]: text_features = [1, 2, 3]

In [2]: author_signature = [3, 2, 1]

In [3]: Diff = [i - j for i,j in zip(text_features, author_signature)]

In [4]: Diff
Out[4]: [-2, 0, 2]

• I edited my question. I tried float , int, str but not working... u can test too – Mano Oct 25 '18 at 16:34
• @Mano - see my update. It works for me! – n1k31t4 Oct 25 '18 at 16:36
• Again, I edited my question.. very strange because I executed this code on the Jupyter notebook & getting a Type Error. – Mano Oct 25 '18 at 16:41
• I was trying to catch the Type Error & No Type Error found ... Hahahaha.... Thanks anyway – Mano Oct 25 '18 at 16:50