[Tutor] UnicodeWarning: Comparing String
-
ialectum at gmail.com
Sun Jan 13 18:36:26 CET 2013
Hi,
I am trying to check if a Unicode string matches data from an Easygui
"enterbox". I spent one hour looking online how to solve this problem
and I'm still stuck because I don't understand all of the explanations I
find. Lots of trial and error didn't help either.
I use Python 2.5.1.
===This is the error message:===
> UnicodeWarning: Unicode equal comparison failed to convert both
> arguments to Unicode - interpreting them as being unequal
I do understand that everything has to be in Unicode for my code to
work, but I do not know how to properly change my code.
===This is my code:===
> # coding: iso-8859-1
>
> from easygui import *
> import sys
>
> good_answer = "pureté" # notice the accute accent
>
> answer_given = enterbox("Type your answer!\n\nHint: 'pureté'")
>
> if answer_given == good_answer:
> msgbox("Correct! The answer is 'pureté'")
> else:
> msgbox("Bug!")
Thank you in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130113/0a1794df/attachment.html>
More information about the Tutor
mailing list