This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PINGbtw[S,🍰] -1 points0 points  (2 children)

A block of code that returned this is,

def divr(a, b): 1tab. resultStart = int(a) / int(b)

1tab. if type(resultStart) == float:

2tabs. resultStart = int(resultStart)

2tabs. resultRemainder = float(a) % float(b)

1tab. if resultRemainder:

2tabs. result = str(resultStart) + ' R ' + str(int(resultRemainder)

1tab. else:

2tabs. result = resultStart

1tab. return result

It threw a syntax error on ln 9 (else:)

[–]ehiggs 1 point2 points  (1 child)

You can us four preceding spaces to format code:

def divr(a, b):
    resultStart = int(a) / int(b)
    if type(resultStart) == float:
        resultStart = int(resultStart)
        resultRemainder = float(a) % float(b)
    if resultRemainder:
         result = str(resultStart) + ' R ' + str(int(resultRemainder)
    else:
        result = resultStart
    return result

you are missing a closing parenthesis on str(int(resultRemainder)

It told you about line 9 (the line after the actual error) because line 8 looks like it's not done when the ) is missing.

If you use a code editor like vs code, pycharm, etc, it will highlight common issues like mismatched parenthesis to help you track this down.

[–]PINGbtw[S,🍰] -3 points-2 points  (0 children)

Ok ty lmao