变量未定义错误

时间:2013-06-05 20:58:34

标签: python

我收到一条错误消息,指出sum1未定义

def zodiacMatch(sum1, sum2):
    sum1 = input("please enter your zodiac number")
    sum2 = input("please enter your other number")
    if sum1 + sum2 <= 7:
        print "low compatibility"

#MAIN#
zodiacMatch(sum1, sum2):
sum1 = input("please enter your zodiac number")
sum2 = input("please enter your other number")

1 个答案:

答案 0 :(得分:2)

试试这个:(如果你的Python版本低于3.x. python --version来检查)

def zodiacMatch(sum1, sum2):
    if sum1 + sum2 <= 7:
        print "low compatibility"

#MAIN#
sum1 = input("please enter your zodiac number")
sum2 = input("please enter your other number")
zodiacMatch(sum1, sum2):

我希望这会有很好的业力:D