5

When I compare these 2 strings, the value I get is False.

a = "comentar"
b = "️comentar"
print(a == b) # False

How could I fix this? I have tried changing the encoding of both strings but it does not have any effect.

You can try it here: https://onlinegdb.com/HJ8xYLPq4

1
  • how did you add the hidden character? Commented Jun 1, 2022 at 18:09

2 Answers 2

10

They are not identical. The first character is different (although it looks identical to the naked eye)

Try

 print([ord(c) for c in a])
 print([ord(c) for c in b])
Sign up to request clarification or add additional context in comments.

Comments

2

If you can ignore small differences like this one, try:

from difflib import SequenceMatcher

word_1 = "comentar"

word_2 = " comentar"

result = SequenceMatcher(a=word_1, b=word_2).ratio() > 0.9

print(result)

This will return True

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.