I am doing an exercise from hackerrank.com.
My main issue with my code is my function returns none with my while loop.
I know I can pass the exercise by not using it as a function but my personal goal is to maintain it as one. Is there a way I can keep my code as a function and not return None?
My Code
def cutOperation(sticks):
currentLine = sticks
while len(currentLine) != 0:
newLine = []
print len(currentLine)
for stick in currentLine:
if stick - min(currentLine) != 0:
newLine.append(stick - min(currentLine))
currentLine = newLine
_ = int(raw_input().strip())
sticks = map(int,raw_input().strip().split(' '))
#First Test Case for sticks = 5 4 4 2 2 8
print cutOperation(sticks)
Result after running code
6
4
2
1
None
#How do I not return none?