2017-11-02 1 views
0

を動作しない場合 - /他の機能が実行されていない場合は、単純な -シンプルパイソン/他の構文は、私はグレードテスト簡単なテスト・スコアラーを作成しようとしているし、あなたの応答を与えるのです

のPythonを -

testScore = input("Please enter your test score") 


if testScore <= 50: 
    print "You didn't pass... sorry!" 
elif testScore >=60 and <=71: 
    print "You passed, but you can do better!" 

エラーがある -

Traceback (most recent call last): 
    File "python", line 6 
    elif testScore >= 60 and <= 71: 
          ^
SyntaxError: invalid syntax 
+1

エラーが何であるとして取るのでしょうか? –

+5

Pythonは高レベルですが英語ではまっすぐではありません。 'elif testScore> = 60と<= 71:'はこの 'elif 60 <= testScore <= 71:' –

+0

に変更する必要があります。ありがとう! –

答えて

5

あなたはelifの声明の中で

testScore = input("Please enter your test score") 


if testScore <= 50: 
    print "You didn't pass... sorry!" 
elif testScore >=60 and testScore<=71: 
    print "You passed, but you can do better!" 
01 testScoreを逃しました
+0

これはPythonのいくつかのバージョンでは動作しません。 –

1

以下の方法で解決すると良いでしょう。数値と比較/照合するときには常に型変換を整数にする必要があります。

入力()Pythonで、一般的に、文字列

testScore = input("Please enter your test score") 
if int(testScore) <= 50: 
    print("You didn't pass... sorry!") 
elif int(testScore) >=60 and int(testScore)<=71: 
    print("You passed, but you can do better!") 
関連する問題