次のコードを出力すると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それは働く:)今私は私が作ったエラーが何であるか理解している。事前に感謝:) –