Python Forum

Full Version: Letters with Accents Not Inputting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
LETTERS WITH ACCENTS NOT INPUTTING

How do I let the user input at the (Mac) Terminal words with letters with accents?

(As in the related thread "Letters with Accents Not Displaying" this is about Python 2.7.10 code in MacOS 10.14.5. Letters display with accents in both my text file (in TextEdit) of Portuguese words and my (Mac) Terminal, both of which are encoded in Unicode (UTF-8).)

1. The simplest try:

y = input("Your answer: ")
followed by equal comparison with a Unicode list entry results in:

Error:
UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
2. The try:

y = input("Your answer ",encoding="utf-8")
results in:

Error:
TypeError: input() takes no keyword arguments
3. The codecs try (matching the solution in thread "Letters with Accents Not Displaying"):

input codecs
y = codecs.input("Your answer ",encoding="utf-8")
results in:

Error:
AttributeError: 'module' object has no attribute 'input'
4. In Python 2 there is another input method raw_input. It fails in the same ways, for example:

input codecs
y = codecs.raw_input("Your answer ",encoding="utf-8")
results in:

Error:
AttributeError: 'module' object has no attribute 'input'
Can anyone point me in the direction of how to let the user input at a (Mac) Terminal words with letters with accents please?