我得到一個無以下代碼的輸出,我不知道它爲什麼是? 有人可以解釋我爲什麼是這樣以及它如何修復? 這裏的代碼,爲什麼它在輸出中顯示None None
def randomQuestions():
q1 = 1
q2 = 2
for i in range(1):
if random.randint(1,2)==1:
a1=int(input(print("Please Enter a Number that is not prime: ",end="")))
if a1>1:
for i in range (2,a1):
if (a1%i)==0:
print("Correct",a1,"is Not a prime number")
break
else:
print("Incorrect",a1,"is a Prime number")
else:
print("Incorrect",a1,"is a Prime number")
else:
a2=int(input(print("Please Enter a Number that is positive: ",end="")))
if a2>0:
print("Correct",a2,"is Positive")
elif a2==0:
print(a2,'Is neither Positive Nor Negative')
else:
print('Incorrect',a2,'is Not Positive')
randomQuestions()
這是輸出;
Please Enter a Number that is not prime: None
@ayban欣賞你的答案:)但現在它給出了以下錯誤; TypeError:input()不帶關鍵字參數 –
確實如此,您還需要刪除'end =「」'。 – ayhan
@ayban它的工作原理:)現在我明白我犯的錯誤是什麼。在此先感謝:) –