I have a simple program that takes data from the user. Here is an abbreviated version of it:
a = "0-1"
b = "0‑1"
print(a in b) # prints False
Problem:
ord(‘-‘) for a = 45
ord(‘‑’) for b = 8209
How can I make sure that the "-" sign is always the same and checking a in b returns True?
>Solution :
The most robust way would be to use the unidecode module to convert all non-ASCII characters to their closest ASCII equivalent automatically.
import unidecode
print(unidecode.unidecode(a) in unidecode.unidecode(b))