Python 2.7
I am learning Python and I cannot understand why the code below gives
Code:
SyntaxError: invalid syntax
Code:
if c == "." or c == "," or c == ":" or c == ";" or c == "!" or c == "?" or c == "'" or c == '"'
I have tried all the possibilities I could think of with the same result (= or using single quotes or spaces and removing the test on any quote).
The problem I am trying to solve consists of 2 arrays of words obtained from splitting 2 strings of UTF-8 text and trying to find if any word in both arrays is terminated by punctuation mark that the split function did not remove. This punctuation mark must be removed to subsequently compare words from the 2 arrays. Here is the code I used:
Code:
array_words = line.split(u" ")# variable 'line' being a line of text with punctuation
for word in array_words:
c = word[-1:]# variable 'c' supposed to hold one character from the right of variable 'word'
Perhaps there is a better way to do that which I do not know.
Can anyone make suggestions?
Thank you for your help.