0

My code is simple. The problem is input command. I try to write python code that accept user string input from the keyboard and display it. But it Generate this error message always SyntaxError: unexpected EOF while parsing

Generally my python code always can't accept user string input from the keyboard. any one can tell me the problem or fix this error message?

this is code

Message = input('> ')
Word = Message.split(' ')
print (Word)

Error Message

Traceback (most recent call last):
  File "C:/Users/My_Computer_Name/PycharmProjects/test/tests.py", line 1, in <module>
    message = input('> ')
  File "<string>", line 1
    Hi hi
        ^
SyntaxError: unexpected EOF while parsing
3
  • See Python unexpected EOF while parsing. You're running the code with Python 2, not Python 3. Commented Mar 1, 2020 at 21:23
  • Tnxs it work i used "raw_input" instead of 'input' Commented Mar 1, 2020 at 21:27
  • 3
    You should switch to Python 3 instead. Commented Mar 1, 2020 at 21:31

1 Answer 1

0

Seems like you're using python 2.x so you would need to do:

Message = raw_input('> ')
Word = Message.split(' ')
print (Word)

I would definitely suggest upgrading to python 3.7 (3.8 is not supported for all packages).

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

2 Comments

Note the bullet point regarding questions that "have already been asked and answered many times before" in the Answer Well-Asked Questions section of How to Answer.
ah well.. good stuff then!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.