SyntaxError: incomplete input

【不具合内容】

Pythonでprint文実行時に発生。

stations = ["東京", "品川", "新横浜", "小田原", "熱海"]
print(stations[1]
  File "<ipython-input-18-6c85ee666727>", line 1
    print(stations[1]
                     ^
SyntaxError: incomplete input

【原因】

print文の「)」閉じカッコがない。

print文以外でも対になるカッコが抜けていたりすると発生する。

【解決方法】

「)」閉じカッコを追記する。

stations = ["東京", "品川", "新横浜", "小田原", "熱海"]
print(stations[1])

コメントを残す

* 印は必須項目です。メールアドレスは公開されません。

次のHTMLタグと属性を使用することができます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください