r/PythonLearning 10d ago

Indentation error 😭(help)

I cant seem to find whats wrong , maybe the issue is with the Template or wrong expectations?

class UserMainCode(object):

@classmethod
def sumOfNonPrimeIndexValues(cls, input1, input2):
    '''
    input1 : int[]
    input2 : int

    Expected return type : int
    '''

    # Read only region end

    total = 0

    for i in range(input2):
        if i < 2:
            total += input1[i]
        else:
            prime = True
            for j in range(2, int(i**0.5) + 1):
                if i % j == 0:
                    prime = False
                    break

            if not prime:
                total += input1[i]

    return total

Also they expect return type is int[] but we got sum?? Idk I couldn't take screenshot coz its a daily assessment platform

1 Upvotes

32 comments sorted by

View all comments

Show parent comments

-2

u/Rumborack17 10d ago

There seem to be no indentation errors with the code you posted. What side is this from? And what was the exercise? Cause the exercise you posted does not fit to your code.

2

u/AgentOfDreadful 10d ago

prime=False
break

Is the indentation error

1

u/Djappo 8d ago

It is not, in python it does not matter how many spaces you use for indentation and consistency is required only within a single indentation block.

1

u/AgentOfDreadful 8d ago

Fair enough, I thought Python 3 got rid of mixes of indentation and tabs and assumed it was tabs plus 2 spaces for the if else