0

I'm using the book "Python In Easy Steps" by Mike Mcrath,and I'm having a issue with the user input project. I keep getting the error "multiple statements found while compiling a single statement".

user = input('Hello, my name is Hal. What is your name?:')

print( ' It is very nice to meet you',user)

I'm using the 3.4.3 version of the IDLE shell to test my code.

1
  • How are you running the code? Is it a separate script? Commented Jul 14, 2015 at 7:44

3 Answers 3

2

You need to execute them one by one :

user = input('Hello, my name is Hal. What is your name?:')

it will ask for input and then:

print( ' It is very nice to meet you',user)

or create a Python script (.py) and then from terminal exexute:

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

1 Comment

IDLE can only do a single statement at once, i.e. in your case: A single line. So you have to paste in all lines individually and execute them.
0

print 'It is very nice to meet you %s' % user

1 Comment

I did not know IDLE could only do one statement at a time. I ran it from the Terminal a few other times and got the same error, but this time it worked. I guess I needed to mess around with the indentations in Notepad. Thanks for the help guys.
0

Try this:

print ('It is very nice to meet you %s' % user)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.