Accent and ñ in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Accent and ñ in python

If I want to put something like print("número") or print("año") Python trows an SyntaxError. How can I write á, é, í, ó, ú and the ñ without an error?

29th Jan 2021, 12:25 AM
Carmen Lucía
Carmen Lucía - avatar
3 Answers
+ 5
in wich context are you running those statements? wich version of python? 2? 3? ...as playground here, and at least python 3 anywhere should good handle accentuated characters ^^
29th Jan 2021, 12:42 AM
visph
visph - avatar
+ 2
and probably under window, I guess ;)
29th Jan 2021, 12:52 AM
visph
visph - avatar
+ 1
Oh it makes sense... I was running python 2.7 and that was the problem... Thanks :)
29th Jan 2021, 12:49 AM
Carmen Lucía
Carmen Lucía - avatar