0

I'm running Python on my mac but I'm encountering this problem.

I'm trying to run the following code:

name = input(’Enter name (max 60 chars): ’)

print(’Hello ’ + name + ’. Welcome’)

But it gives me this error:

File "/Users/mac/Documents/workspace/helloworld/hello.py", line 1
SyntaxError: Non-ASCII character '\xe2' in file /Users/mac/Documents/workspace/helloworld/hello.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

What do I do? I also can't use single quotes. Since I'm level 1 I can't post images, so here's a picture of the version of my Python launcher.

TigerhawkT3
  • 48,464
  • 6
  • 60
  • 97
Lorren112
  • 93
  • 1
  • 2
  • 6
  • Did you look at PEP 263 and try to put an encoding comment at the top of your file? – Patrick Maupin Jul 29 '15 at 03:17
  • Is that your complete hello.py ? – Anand S Kumar Jul 29 '15 at 03:17
  • That's not related to `input()`; something is wrong with your file's text encoding. – TigerhawkT3 Jul 29 '15 at 03:18
  • 1
    I think you should change this quote `’` to `'` – Iron Fist Jul 29 '15 at 03:18
  • 3
    The other question, I suppose, is if a real text editor is being used, or something that does some sort of smart quoting. – Patrick Maupin Jul 29 '15 at 03:19
  • It might be good to double check your Python version, and your system settings (anything related to language or encoding). Python 3 should use UTF-8 by default, but it's decided to use ASCII - the smart quote will still give an error, but it should be a *different* one ("invalid character in identifier"). – lvc Jul 29 '15 at 03:22
  • After fixing your question's formatting, it's much easier to see the problem: those aren't ordinary ("straight") quotes like `'`. They're smart quotes like `’`. – TigerhawkT3 Jul 29 '15 at 03:24

1 Answers1

0

Please add this in your File and try again.

# -- coding: utf-8 --

If you have copied and pasted the code from some other source, then I suggest you delete and re-type the single quote character(').

RPradeep
  • 6,564
  • 1
  • 13
  • 11