0

It is about 10 motivation stories where i have to "grade" them by looking at several aspects. The first if statement checks if the length of the story is more then 280 characters, the second if statement checks if the first letter is a capital letter. I want to store the scores in candidscore so if candid 2 has a length > 280 and the first letter is a capital one i want the candidscore[1] to be 2.

Code:

candidscore = numpy.zeros(10)

for i in range(0, 9):
    if lengthmot[i] > 280:
        candidscore[i] =+ 1
    if lengthmot[i] > 0:
        if motivation[i][0].isupper():    
            candidscore[i] =+ 1

problem: The array candidscore does initialy look like: array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) so that works.

It checks if the length > 280, this works to and the array has several ones in it. array([ 1., 0., 1., 1., 1., 0., 1., 0., 1., 0.]). So this works as well

Then it should checks if the first letter is a capital letter, I think it does check it but it only increments the score where it is still 0 after the first if statement so it looks like this: array([ 1., 1., 1., 1., 1., 1., 1., 0., 1., 1.]).

However according to the data it should/i want it to look like this: array([ 2., 1., 2., 2., 1., 1., 1., 0., 1., 2.]).

I do not understand why the elements which are already 1 do not increment.

1
  • 5
    =+ does not equal +=. Commented May 30, 2017 at 7:54

1 Answer 1

5

You are using =+ instead of +=, change that and it should work

Sign up to request clarification or add additional context in comments.

2 Comments

wow thank you such a small error i have been overlooking for days
Happy to help, please accept the answer if it currently works.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.