-2

I'm trying to do this codefights task:

Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array.

So here's my code:

def almostIncreasingSequence(sequence):
def checa(sequence):
    cont = 0
    copia1 = copia2 = sequence
    for i in range(len(sequence)-1):
        while(cont == 0):
            if(sequence[i] >= sequence[i+1]):
                del(copia1[i])
                del(copia2[i+1])
                cont += 1
    if(all(copia1[j] < copia1[j+1] for j in range(len(copia1)-1)) == True):
        return True
    elif(all(copia2[j] < copia2[j+1] for j in range(len(copia2)-1)) == True):
        return True
    else:
        return False

I can't see my flaws here and it's returning None every single time.

  • 8
    where is your `return` ? – scharette Jul 10 '18 at 17:36
  • 2
    What is `Null`? Can't say I'm familiar with that value. – Kevin Jul 10 '18 at 17:38
  • @Kevin haha good catch. – scharette Jul 10 '18 at 17:39
  • I added the `return` still getting `none`. – Rodrigo Meireles Jul 10 '18 at 18:12
  • Someone please come back to my question. I added the `return` as asked but no one will answer it now... – Rodrigo Meireles Jul 10 '18 at 18:26
  • Hi. if you ask for help, you should take care to show all relevant information and the exact code in your question. We can't see what see on your computer, this question is all we know. We can't guess the missing information. First you forgot the return statement, now after editing there are two `def...:` lines, which also doesn't make much sense. And you never showed the code that calls your function and the input data. That makes it quite difficult to answer. Please update your question, in the state it is now, it's hard to answer. – jps Jul 10 '18 at 21:18

1 Answers1

2

You did not include a return statement, thus your function will always return None

scharette
  • 9,437
  • 8
  • 33
  • 67