2016-04-18 10 views
-3

この印刷機能は構文エラーを出していますが、なぜうまくいかないのですか?任意の助けPython - 構文エラーを出すprint( "abc")

if teacher == "no": 
    name = input("What is your name?") 
    class_code = str(input("What class are you from? 1, 2 or 3?") 
    print("Welcome to the Arithmetic Quiz, ",name) 

ありがとう!

+0

にあなたは、Python 3のコードを実行するためのpython 2インタプリタを使用していますか? – BlackBear

+0

@BlackBearここに示す 'print'は、Python 2とPython 3の両方で有効です。 – chepner

+0

これがPython 2の場合は、' input'ではなく 'raw_input'を使うべきです。 Python 3の 'input'とPython 2の' raw_input'は両方とも文字列を返します。したがって、 'str()'の呼び出しは不要です。 – chepner

答えて

1

変更このライン

class_code = str(input("What class are you from? 1, 2 or 3?") 

class_code = str(input("What class are you from? 1, 2 or 3?")) 
+0

母はおかげでたくさん、それを見つけませんでした! –

関連する問題