0
votes

I'm trying to find a way to fix this syntax error. I can't seem to find it to make the program run correctly. This is my code below

wrong = 0
test = raw_input("Please enter a 4 digit integer:")

def start(test):




    if test.isdigit():

        if wrong(test)==True:
            print 'Invalid input.  Four integers must be entered.'
        else:
            numbers = []

            for a in test:
                digits.append(a)
            a=calc(int(digits[0]))
            b=calc(int(digits[1]))
            c=calc(int(digits[2]))
            d=calc(int(digits[3]))


            code = str(c)+str(d)+str(a)+str(b)

            print 'The encrypted integer is:',code


    else:

        print 'You input wrong. Use numbers only.'


def calc(num):
    num+=7
    num%=10
    return num




def error(test):

    if len(test)<4 or len(test)>4:
        return True
    else:
        return False






start(test)

AND the fixed is ...

digits = 0 wrong = 0 test = raw_input("Please enter a 4 digit integer:")

def start(test):

if test.isdigit():

    if wrong(test)==True:
        print 'Invalid input.  Four integers must be entered.'
    else:
        numbers = []

        for a in test:
            digits.append(a)
        a=calc(int(digits[0]))
        b=calc(int(digits[1]))
        c=calc(int(digits[2]))
        d=calc(int(digits[3]))


        code = str(c)+str(d)+str(a)+str(b)

        print 'The encrypted integer is:',code


else:

    print 'You input wrong. Use numbers only.'

def calc(num): num+=7 num%=10 return num

def wrong(test):

if len(test)<4 or len(test)>4:
    return True
else:
    return False

start(test)

2
Don't keep us in suspense: what was the error? - Michael Lorton
Please remember to show the error message you are getting. We can't see your screen from here, so we have to guess. If we guess wrong, you're wasting both your time and ours. - Greg Hewgill
Ok, it was a simple error of not naming things correctly when I called them. - Pr0cl1v1ty

2 Answers

2
votes

You've called a function named wrong() but defined a function named error(). Is that the problem you're seeing?

1
votes

Don't you mean if error(test)? 'wrong' is not a function.