0

This python3.3 code on win 7, why I got error:

import random

guesses_made = 0

name = raw_input('Hello! What is your name?\n')

number = random.randint(1, 20)
print "Well, {0}, I am thinking of a number between 1 and 20" # error here !!!


**print "Well, {0}, I am thinking of a number between 1 and 20"
                                                            ^
 SyntaxError: invalid syntax**

Thanks !!!

user2420472
  • 1,127
  • 1
  • 12
  • 20

2 Answers2

1

Two things:

In python 3, raw_input() has been changed to input().

Also, print is no longer a statement but a function, so you must do:

print("Well, {0}, I am thinking of a number between 1 and 20")
TerryA
  • 58,805
  • 11
  • 114
  • 143
0

I think that last line should read:

print("Well, {0}, I am thinking of a number between 1 and 20".format(name))

This was tested. I am pretty new to p3.3, so go easy on me :)

AMADANON Inc.
  • 5,753
  • 21
  • 31