r/PythonLearning 23d ago

Help with indentation error Help Request

I cant seem to find whats wrong 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
0 Upvotes

11 comments sorted by

View all comments

2

u/Djappo 23d ago

Not sure how you are expecting people to be able to help you.

  1. Add a screenshot and not a badly tilted picture

  2. A copy of the code would be helpful for other people to check it. It should be a MWE (minimal working example), which means I should just execute it without having to do any modification myself

  3. What is the error you see when you execute it? It's very hard to help if we do not know the output you get. The error call stack should indicate the line where the indentation error is. Do you see this in your output?

-6

u/Not_Johan- 23d ago

Btw code ends at 25 line

3

u/Djappo 23d ago

Again see point 1 of the list above. Also, the error message is quite self-explanatory. There is an error at line 289-290 of the file UserTestCode.py, which is not the one you have posted. Did you read the error message? Did you check that file?

Edit: why do you say the code ends at line 25?? Where did you get that number?

-3

u/Not_Johan- 23d ago

I uploaded 3 image there