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.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99

1 Answers1

5

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

Isdj
  • 1,835
  • 1
  • 18
  • 36