1
age = int(input("Please type your age:"))
if int(age) >= 18:
    print("Sorry, you couldn't enter!")
else:
    print("Congratulation, have a good time!")

SyntaxError: Non-UTF-8 code starting with '\xa3' in file go to.py on line 1, but no encoding declared;

Why?

6
  • You have a space between input and ("Please Commented Jul 15, 2018 at 13:23
  • 1
    @dmitryro Extra spaces like that won't cause a problem. Commented Jul 15, 2018 at 13:25
  • Your "(" before Please is weird. Copy paste into a cmd prompt and you will see. Commented Jul 15, 2018 at 13:25
  • 1
    @PM 2Ring Yes, but using "(" instead of "(" will Commented Jul 15, 2018 at 13:27
  • @dmitryro Most certainly! soon's answer is correct. Commented Jul 15, 2018 at 13:32

2 Answers 2

7

Your code contains several characters unrecognizable by python interpreter. They looks like regular ( and ::

In [8]: ord('(')
Out[8]: 40

In [9]: ord('(')
Out[9]: 65288

In [10]: ord(':')
Out[10]: 58

In [11]: ord(':')
Out[11]: 65306

It seems like you copied the code from somewhere - just manually replace all parentheses and colons with valid characters

Sign up to request clarification or add additional context in comments.

1 Comment

FWIW, that "\N{FULLWIDTH COLON}", U+FF1A doesn't look like a colon in this old font on my machine, it looks a bit like Arabic.
1

First problem

There is no text but encoded text.

If a file was written from text then the writer chose a character encoding. Communication of a text file includes the bytes and knowledge of the character encoding.

You are telling the compiler (probably by default) that your file was encoded with UTF-8. It's saying that it can't be (and it's probably correct). So, you first have to tell it which encoding it is.

On the other hand, since UTF-8 is a very common encoding for the Unicode character set and Unicode has all the characters you are likely to ever use, and it's the default for many, many programs, including Python, you could convert the file to UTF-8.

Second problem

@soon's answer deals with the secondary problem of using characters for syntax that aren't part of the syntax. They are confusables.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.