我不知道我在使用 if elif 和 else 的 python 条件语句代码中哪里错了
i dont know where im wrong in this python code of conditional statements using if elif and else
this is what I'm trying to do but it keeps on saying something is wrong in line 15
您的代码中存在错误,因为您不能在 else
语句之后添加 elif
语句。
您的代码
if #something:
#something
else #something:
#something
elif #something:
#something
正确方法:
if #something:
#something
elif #something:
#something
else #something:
#something
问题是嵌套的 if 和 else 应该是有意的
否则第一个 else 与第一个 else
avarage_grade =7
attendance=1
if (avarage_grade>=6):
if(attendance>=0.8):
print('student has passed')
else: #here
print("student has failed due to low attendance rate") # and here
elif(attendance>0.8):
print("student has failed due to low avarage_grade")
else:
print("student has failed due to low avarage_grade and low attendance rate")
还请 post 您的代码也...供将来任何人查看
this is what I'm trying to do but it keeps on saying something is wrong in line 15
您的代码中存在错误,因为您不能在 else
语句之后添加 elif
语句。
您的代码
if #something:
#something
else #something:
#something
elif #something:
#something
正确方法:
if #something:
#something
elif #something:
#something
else #something:
#something
问题是嵌套的 if 和 else 应该是有意的 否则第一个 else 与第一个 else
avarage_grade =7
attendance=1
if (avarage_grade>=6):
if(attendance>=0.8):
print('student has passed')
else: #here
print("student has failed due to low attendance rate") # and here
elif(attendance>0.8):
print("student has failed due to low avarage_grade")
else:
print("student has failed due to low avarage_grade and low attendance rate")
还请 post 您的代码也...供将来任何人查看