2017-03-16 89 views
-2

我一直在通過互聯網和其他許多人一樣查找,找不到答案我一直在獲取TypeError:'str'對象不可調用 bug每次我嘗試運行我的計劃,旨在提出一個問題,爲用戶解答然後加入了他們的得分的時候,我需要解決這個問題,如果我想繼續TypeError:'str'對象不可調用

input = ("What is your name?") 
print = ("I will ask you 10 questions and give you three choices for each question \n IMPORTANT! PLEASE KEEP YOUR CAPSLOCK ON") 

score = 0 
score = int(score) 

q1 = input("What piece of code would show a word/sentence and nothing else \n A. print() \n B. input() \n C. int(print) ") 

if q1 == ("A") : 
    print ("Well done! That is correct") 
    score = score + 1 
    print ("Your score is",score,) 
elif q1 == ("B") : 
    print ("That is incorrect") 
elif q1 == ("C") : 
    print ("That is incorrect") 

請幫我,謝謝!

+6

你用字符串覆蓋了'print'函數。使用不同的變量名稱 –

+1

@ Farhan.K我懷疑OP並不意味着要分配給這個名稱,他們打算實際調用print()。 –

+1

@DanielRoseman是的,可能是這種情況。 @Pegaferno在這種情況下,你需要在'print'後面去掉'=' –

回答

5
input = ("What is your name?") 
print = ("I will ask you 10 questions and give you three choices for each question \n IMPORTANT! PLEASE KEEP YOUR CAPSLOCK ON") 

覆蓋inputprint功能,具有字符串。使用

name = input("What is your name?") # the input will be stored in name 
print("""I will ask you 10 questions and give you three choices for each question. 
IMPORTANT! PLEASE KEEP YOUR CAPSLOCK ON.""")