-3

This is my code:

x = input ( "Hello what is your name : ")
print ("Nice to meet you " + x)
y = input ("Would you like to play Ted Ryan's Great Adventure Game? If you would like to play write yes if not write no")
y = yes
if y == "yes" print "lets begin"

What I am trying to is if the input for the question "Would you like to play Ted Ryan's Great Adventure Game? If you would like to play write yes if not write no" is yes I want it to print let's begin.

However, I sometimes get the errors "EOF while parsing" or "syntax error".

Thomas Orozco
  • 53,284
  • 11
  • 113
  • 116

4 Answers4

1

In Python 2, You should use raw_input, not input.

Input actually eval's whatever the user inputs, which is why you get a EOFError if the user's name includes a single ', or a SyntaxError if their name isn't valid Python code.

--

Note that you seem to have an indentation problem on your last line. It should be:

if y == "yes":
    print "lets begin"
Thomas Orozco
  • 53,284
  • 11
  • 113
  • 116
0

Few things:

  1. y = yes what is that line?
  2. x = input ( "Hello what is your name : ") if you expect the user to input string you should be using x = raw_input ( "Hello what is your name : ") instead
  3. if y == "yes" print "lets begin" should be -> if y == "yes": print "lets begin" with colon
krystan honour
  • 6,523
  • 3
  • 36
  • 63
Anton Belev
  • 11,963
  • 22
  • 70
  • 111
0
x = input ( "Hello what is your name : ")
print ("Nice to meet you " + x)
y = input ("Would you like to play Ted Ryan's Great Adventure Game? If you would like to play write yes if not write no")
if y == "yes":
    print ("lets begin")
else:
    print ("No we cant play")
ZdaR
  • 22,343
  • 7
  • 66
  • 87
0

try raw_input() instead of input

name = raw_input( "Hello what is your name : ")
print ("Nice to meet you " + name)
answer = raw_input("Would you like to play Ted Ryan's Great Adventure Game? If you would like to play write yes if not write no")
if answer == "yes":
    print "lets begin"
TheHermit
  • 181
  • 5