如何在一行中同时使用 OR 条件和“<=”和“>=”函数
How do I use both the OR condition and the '<=' and '>=' functions in a single line
这里是初学者。我已经发布了所有代码,但我相信错误包含在底部以粗体显示的两行特定代码中。显然我的语法是错误的,但我不明白怎么办;我已经尝试为数字 and/or 重新指定 INT,将 OR 条件的每一侧放在括号中,但没有任何效果。我屏幕上的错误 marker/pointer 似乎位于大于 than/less 的符号下方。即使我简化删除 OR 条件,它也会抛出错误。
final_score = str(digit_one) + str(digit_two)
print(f"So the two digit score is {(int(final_score))}")
# 3of3 Final Outputs
**if final_score (<= 10) or (>= 90):**
print(f"Your score is {final_score}, you go together like coke and mentos.")
**if final_score >= 40 and <= 50:**
print(f"Your score is {final_score}, you are alright together.")
else:
print(f"Your score is {final_score}.")
您只需在每个条件之前重复变量即可。此外,python 语法不需要括号。试试这个:
if final_score <= 10 or final_score >= 90:
print(f"Your score is {final_score}, you go together like coke and mentos.")
if final_score >= 40 and final_score <= 50:
print(f"Your score is {final_score}, you are alright together.")
else:
print(f"Your score is {final_score}.")
这里是初学者。我已经发布了所有代码,但我相信错误包含在底部以粗体显示的两行特定代码中。显然我的语法是错误的,但我不明白怎么办;我已经尝试为数字 and/or 重新指定 INT,将 OR 条件的每一侧放在括号中,但没有任何效果。我屏幕上的错误 marker/pointer 似乎位于大于 than/less 的符号下方。即使我简化删除 OR 条件,它也会抛出错误。
final_score = str(digit_one) + str(digit_two)
print(f"So the two digit score is {(int(final_score))}")
# 3of3 Final Outputs
**if final_score (<= 10) or (>= 90):**
print(f"Your score is {final_score}, you go together like coke and mentos.")
**if final_score >= 40 and <= 50:**
print(f"Your score is {final_score}, you are alright together.")
else:
print(f"Your score is {final_score}.")
您只需在每个条件之前重复变量即可。此外,python 语法不需要括号。试试这个:
if final_score <= 10 or final_score >= 90:
print(f"Your score is {final_score}, you go together like coke and mentos.")
if final_score >= 40 and final_score <= 50:
print(f"Your score is {final_score}, you are alright together.")
else:
print(f"Your score is {final_score}.")