一个猜数字的小游戏,但是pycharm中存在以下错误,使用IDLE打开是没有问题的。请问原因是什么?
#guess number
import random #use import function convert random module
num = random.randint(0,11) #create random int
temp = input ('Please type you guess number: ') #type random str
guess = int (temp) #temp convert to int, if the str is decimal could use int(float(temp)) transfer
while guess != num: #while loop
print ("Sorry! You are wrong.")
temp = input ('Please type the number again: ')
guess = int (temp)
if guess == num:
print ('Amazing!')
else:
if guess > num:
print ("The number is high.")
else :
print ('The number is low.')
print ('Congragulation!')
D:\Anaconda\python.exe "C:/Users/Sky Talk/PycharmProjects/untitled/Key"
File "C:/Users/Sky Talk/PycharmProjects/untitled/Key", line 7
print "dict['name']:",dict['name']
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("dict['name']:",dict['name'])?
Process finished with exit code 1
答案 0 :(得分:0)
Print(words)是一个接受参数的命令。使用打印功能时,必须使用括号,否则会出现错误。使用错误消息给您的建议:
print("dict['name']:",dict['name'])