Python Forum
If statement containing apostrophe - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: If statement containing apostrophe (/thread-19637.html)

Pages: 1 2


RE: If statement containing apostrophe - ThomasL - Jul-09-2019

(Jul-09-2019, 09:09 AM)AshBax Wrote:
Output:
['I don’t know'] I don't know WRONG! i want to see : I don’t know
maybe it´s because the two apostrophes are not the same?
’ != '


RE: If statement containing apostrophe - AshBax - Jul-09-2019

I have been able to create a work around by using the "re" package:
from line 29 onwards:
for i in range(0,len(gameplay_A)):
    answer = input(gameplay_A[i] + "\n")
    new_answer = re.sub("[^a-zA-Z]+", "", answer)
    new_gameplay = re.sub("[^a-zA-Z]+", "", gameplay_B[i])
    if answer.lower() == gameplay_B[i].lower() or new_answer.lower() == new_gameplay.lower():