Skip to content
Advertisement

“Python: ‘unicodeescape’ codec can’t decode bytes…: malformed N character escape” when I’m trying to type an input statement

JavaScript

I was creating a program to store employee-related data. as a mini project. However as I tried to run my (barely-completed program_ I get the unicode error message and Python highlights the parenthesis after input. I’ve googled for answers but it seems like the common issue is related to file paths which I am not dealing with here.

This is just a section of the entire code and if needed I will edit this post and post it here.

Also when I tried to run it by double clicking the file the command prompt just shuts down immediately, but if I remove correct_data = input("Is this the correct employee data [YN]: ") then it works normally.

Advertisement

Answer

Either replace with /, i.e.:

JavaScript

or escape by replacing it with \, i.e.

JavaScript

or use a raw string:

JavaScript

For more details see string literals from the documentation.

Advertisement