SyntaxError: invalid syntax in true love exercise and I can't find problem

SyntaxError: invalid syntax in true love exercise and I can't find problem

我正在学习Python,我对下面的代码有疑问。看起来对我来说一切都很好,但我经常出错。怎么了?

#  Don't change the code below 
print("Welcome to the Love Calculator!")
name1 = input("What is your name? \n")
name2 = input("What is their name? \n")

#  Don't change the code above 

#Write your code below this line 

combined_name=name1+name2
combined_name_lower = combined_name.lower()

t = combined_name_lower.count("t")
r = combined_name_lower.count("r")
u = combined_name_lower.count("u")
e = combined_name_lower.count("e")

true = t + r + u + e

l = combined_name_lower.count("l")
o = combined_name_lower.count("o")
v = combined_name_lower.count("v")
e = combined_name_lower.count("e")

love = l + o + v + e

love_score = int(str(true) + str(love))

if love_score < 10 or > 90:
    print(f"Your score is {love_score}, you go together like coke and mentos.")
elif love_score >= 40 and <= 50:
    print(f"Your score is {love_score}, you are alright together.")
else:
    print(f"Your score is {love_score}.")

只是一个打字错误,更正:

if love_score < 10 or love_score > 90:

elif love_score >= 40 and love_score <= 50:

您应该在 post 中包含错误消息:

  File "main.py", line 29
    if love_score < 10 or > 90:
                          ^
SyntaxError: invalid syntax

问题出在您尝试使用的比较语法上。应该是

    if not 10 <= love_score <= 90:

    if love_score < 10 or love_score > 90: