首页 > 解决方案 > 为什么我在 Python 上使用 If 时会出现语法错误

问题描述

我是 Python 的一个真正的新手(现在已经这样做了大约 3 天),我有一个任务要求我创建一个对话。它开始很好,直到第 13 行我使用了 if 但它告诉我存在语法错误。我已经仔细检查了很多次,看看我是否遗漏了一些东西(变量是已知的,有一个冒号等......)但我无法指出哪里出了问题,所以我把它贴在这里。这是代码

nom=input("Quel est votre nom?")
print('Enchanté',nom,'je suis Roxanna, et je vais vous aider à trouver votre orientation, je suis en quelque sorte une CPE virtuelle')
print('Bien, pour commencer, veuillez choisir votre matière préférée au Lycée parmi cette liste;')
print('SVT , SES , Arts , Langues Vivantes , EPS , SNT , Histoire, Maths')
matiere=input("Quelle est votre matière préférée")
if matiere=="SVT" or matiere=="SES" or matiere=="Maths" or matiere=="Arts" or matiere=="Langues Vivantes" or matiere=="EPS" or matiere=="SNT" or matiere=="Histoire"  :
 print("Je vois que vous avez un préférence pour la matière suivante:",matiere, ", nous pouvons donc continuer")
else:
 print("Erreur, la matière que vous avez choisie ne fait pas partie de la liste, vérifiez bien l'orthographe des mots!")
note=int(input("Combien avez-vous eu de moyenne en "+matiere+" en Terminale?")
if note>13 :
 print("Très bien, vous êtes un as en"+matiere)```

标签: pythonpython-3.xpython-2.7

解决方案


note=int(input("Combien avez-vous eu de moyenne en "+matiere+" en Terminale?")

您在)此行的末尾缺少 a 。


推荐阅读