2013-02-23 77 views

回答

11

在python3,print功能返回None。所以,行:

print ("number of donuts: ") +str(count) 

你有None + str(count)

你可能想要的是使用字符串格式化:

print ("Number of donuts: {}".format(count)) 
+0

+1格式化 – Ric 2013-02-23 03:13:59

+0

非常感謝您的幫助! – user2101517 2013-02-23 03:15:32

5

你的括號是在錯誤的地方:這裏

print ("number of donuts: ") +str(count) 
          ^

移動它:

print ("number of donuts: " + str(count)) 
             ^

或者只是使用逗號:

print("number of donuts:", count) 
+0

非常感謝您的幫助! – user2101517 2013-02-23 03:15:59

+0

這適用於我。謝謝..!! – 2016-09-29 10:51:04

1

在Python 3中print不再是一個聲明。你想要做的,

print("number of donuts: " + str(count)) 

,而不是添加到打印()的返回值(這是無)

相關問題